|
You can use XPathNavigator and XPathNodeIterator (in the System.Xml.XPath namespace) to navigate an "unknown" XML data source.
|
|
|
|
|
I should have explained better. The instructions are XML, but the datasource could be any number of things. It is either a List<t> or just an Object. If it is an object I want to get at it's properties as in the c# code I posted below, if it is a List<t> then I will loop through it and access it the same way. Just need to figure out how to access that data by name.
|
|
|
|
|
Then perhaps the PropertyInfo class of the System.Reflection namespace is what you're looking for ...
|
|
|
|
|
Now THAT sounds promising. Thanks for the direction.
Cheers, --EA
|
|
|
|
|
Also check out the MemberInfo class.
One typically starts at the "member-level" (GetMembers() of the type), and then depending on the "member type" (property; method) of each member, goes from there.
|
|
|
|
|
This is a weird one from a client. I've been racking my brains on how to do this, but as yet, no success. Starting from a random date, to another random date (school term dates), how can I flag up the second Tuesday of each calendar month? I will accept hoots and jeers
|
|
|
|
|
You could determine all the second Tuesdays for a year or two and then select the ones that fall within the target date range. Here are the second Tuesdays for 2014:
for ( int i = 0; i < 12; i++ ) {
DateTime beginDate = new DateTime( 2014, 01 + i, 01 );
int dayDiff = ( int ) DayOfWeek.Tuesday - ( int ) beginDate.DayOfWeek;
DateTime secondTuesday = beginDate.AddDays( dayDiff + ( dayDiff < 0 ? 14 : 7 ) );
Console.WriteLine( "2nd Tuesday: {0}", secondTuesday );
}
|
|
|
|
|
Well, the brute force method is to find the first Tuesday of a month and add 7 days. No, I'm not trying to be funny here, here's a simple way to achieve this:
public DateTime FindSecondTuesday(int month, int year)
{
int day = 1;
DateTime date = new DateTime(year, month, 1);
while (true)
{
if (date.DayOfWeek == DayOfWeek.Tuesday)
return date.AddDays(7);
date = date.AddDays(1);
}
} All you need do then, is call it for each month and year that you want to get the date from.
|
|
|
|
|
No need for a loop - just switch on the DayOfWeek :
public DateTime FindSecondTuesday(int month, int year)
{
DateTime date = new DateTime(year, month, 1);
switch (date.DayOfWeek)
{
case DayOfWeek.Sunday:
{
return date.AddDays(9);
}
case DayOfWeek.Monday:
{
return date.AddDays(8);
}
case DayOfWeek.Tuesday:
{
return date.AddDays(7);
}
case DayOfWeek.Wednesday:
{
return date.AddDays(13);
}
case DayOfWeek.Thursday:
{
return date.AddDays(12);
}
case DayOfWeek.Friday:
{
return date.AddDays(11);
}
case DayOfWeek.Saturday:
{
return date.AddDays(10);
}
default:
{
throw new InvalidOperationException("Lousy Smarch weather!");
}
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I would take the essence of the other 2 solutions, apply ROW_NUMBER() partitioned over the date component and select the row number 2 for each month. Turn that into a view and select the record for a month/year
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks to everyone who answered my plea. - I've since found out that the meeting on the second Tuesday of the month is purely at one persons discretion, so I've decided to let that person enter the day on the timetable themselves.
Thanks again, your answers were most appreciated.
|
|
|
|
|
can we connect SQLite using visual studio?
|
|
|
|
|
You have my permission
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Yes.
Open the Server Explorer pane, and right click "Data Connections"
From the context menu, select "Add Connection..."
Use the "Change..." button to select the "Data source"
Select "System.Data.SQLite Database File" from the list, and press OK
Browse to your database, and set up the other parameters - then press OK
In the Server explorer pane, right click the database and select "Properties".
In the Properties pane, you will see a connection string you can copy and paste into your application or config file.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Entity framework connects to SQLIte easily.
|
|
|
|
|
How we can shared any folder on all user of LAN using c# code. Sir i am making a software where I want to make shared folder on all user of LAN without any Login.
please help me to do it ..
thank you In Advance..........
|
|
|
|
|
If it's a file-sharing network (like Windows networking) you don't need any code to do this, just share the directory (through right click, properties, sharing).
If it's just a TCP network then you probably want to use an SFTP server.
|
|
|
|
|
|
Hello everybody,
i am pretty new in C# and have a question about how to customize the "Popup orientation".
I have realized a popup with a "custom Placement" which is working gut. However i´ll like my Popup to recognize when there´s not enough place in the window to be fully displapled and to Change the way to appear (from right to left for example).
<Grid Name="backgroundGrid" Width="48" Height="48">
<Rectangle Name="Rect" Fill="Orange" />
<Popup Name="PopupInfo" AllowsTransparency="True" IsOpen="{Binding ElementName=backgroundGrid, Path=IsMouseOver, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" PlacementTarget="{Binding ElementName=backgroundGrid}" Placement="Custom" >
<Canvas Width="200" Height="100">
<Path x:Name="Container" Canvas.Left="37" Canvas.Top="10" Data="M 0,40 L15,50 15,80 150,80 150,0 15,0 15,30" Fill="LightGray" Height="52" Stretch="Fill" Width="130">
<Path.Effect>
<DropShadowEffect Color="Black" ShadowDepth="10" />
</Path.Effect>
</Path>
<TextBlock Canvas.Left="50" Canvas.Top="28" Width="107" Height="22" Margin="10,0,0,0" Text="Popup with text...." TextWrapping="Wrapwithoverflow" />
</Canvas>
the code behind:
PopupInfo.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(placePopup);
public CustomPopupPlacement[] placePopup(Size popupSize, Size targetSize, Point offset)
{
CustomPopupPlacement placement1 = new CustomPopupPlacement(new Point(10, -12), PopupPrimaryAxis.Vertical);
CustomPopupPlacement placement2 = new CustomPopupPlacement(new Point(0, 0), PopupPrimaryAxis.Horizontal);
CustomPopupPlacement[] ttplaces = new CustomPopupPlacement[] { placement1, placement2 };
return ttplaces;
}
I hope to get a Feedback from someone here.
Phil B.
|
|
|
|
|
Hi,
I want to convert a number from exponential form to decimal format , ie in [dot] "." notation. For example I wish to compute 0.5 ^ 100 I desire the answer to be "0.0000000000000000000000000000007888609052210118054117285652827862296732064351090230047702789306640625" instead of 7.88860905221012E-31.
I tried using
string temp=Math.Pow(0.5,100).ToString();
decimal d = Decimal.Parse(temp, System.Globalization.NumberStyles.Float);
but this did not help. Please suggest.
|
|
|
|
|
I suggest you read up on the decimal specification[^] as you are using the wrong tool for that job!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
i used this code but my picturebox is changing value but my image in not fitting in that picturebox.. it comes half or first quadrant etc.
so please help me in this
private void Calculate_btn_Click(object sender, EventArgs e)
{
Bitmap sourceimage = (Bitmap)pictureBox2.Image.Clone();
int height = sourceimage.Size.Height;
int width = sourceimage.Size.Width;
float nPercent = 0;
float nPercentW = 0;
float nPercentH = 0;
int newheight = Convert.ToInt32(height_txt.Text);
int newwidth = Convert.ToInt32(width_txt.Text);
nPercentW = ((float)newheight / (float)height);
nPercentH = ((float)newwidth / (float)width);
if (nPercentH < nPercentW)
nPercent = nPercentH;
else
nPercent = nPercentW;
int destWidth = (int)(width * nPercent);
int destHeight = (int)(height * nPercent);
Bitmap b = new Bitmap(destWidth, destHeight);
Graphics g = Graphics.FromImage((Image)b);
g.DrawImage(sourceimage, 0, 0, destWidth, destHeight);
pictureBox3.Image = sourceimage;
pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
|
|
|
|
|
how to load a partition/ drive in text box?
|
|
|
|
|
It's not even a 'Good morning'! It's maybe a 'Go' - go and improve the question so we can help you!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|