Consider the two arrays:
string[] str = new string[1];
str[0] = "str";
string[] str1 = new string[2];
str1[0] = "str1";
str1[1] = "str2";
To append an two arraycollections:
str = str.Concat(str1).ToArray(); //the result was stored in the str array. this will work only in .net 2008
To add new element in the array:
Array.Resize(ref str, newSize);
str[newSize-1] = "newvalue";
preserving Array elements using c#.net
Convert string to datatime format
1.
string str = "24/10/2008";
DateTime dt = DateTime.ParseExact(str, "dd/MM/yyyy",
Thread.CurrentThread.CurrentCulture);
2.DateTime date = System.DateTime.ParseExact(str, "dd/MM/yyyy", null);
DateTime date = System.DateTime.ParseExact(str, "HH:mm:ss", null);
Effect of Double in .net
Did u feel its a best way to use double in your application.
Test the following scenario:
double a=0.3;
double b=0.1+0.1+0.1;(or)0.2+0.1;
if(a==b)
MessageBox.Show(r u great?);
else
MessageBox.Show(u r great!);
if u put float u wont get the same output.
There is not only problem in using this format. but there are lot of issues and doubt while using double datatype. So consider twice before using double in your application
Solution: We cant say it as an error. in Java also the same thing will happen. its some double precision format.
Better using decimal is a good solution.
Linq for XML .net 2008
Language integrated query for xml
Its very similar to .net 2005 xml processing. the feature added here in .net 2008 is linq.
We can query into the xml elements directly like sql queries.
Also we do the same task with easy and less line of codes(loc) using linq. We can also write events for nodes so any triger on the node are watchable.
For more and through ref search : http://msdn.microsoft.com/en-us/library/bb308960.aspx
System.Windows.Forms.Timer vs. System.Threading.Timer vs. System.Timers.Timer
| Feature description | System.Timers.Timer | System.Threading.Timer | System.Windows.Forms.Timer |
| Support for adding and removing listeners after the timer is instantiated. | Yes | No | Yes |
| Supports call backs on the user-interface thread | Yes | No | Yes |
| Calls back from threads obtained from the thread pool | Yes | Yes | No |
| Supports drag-and-drop in the Windows Forms Designer | Yes | No | Yes |
| Suitable for running in a server multi-threaded environment | Yes | Yes | No |
| Includes support for passing arbitrary state from the timer initialization to the callback. | No | Yes | No |
| Implements IDisposable | Yes | Yes | Yes |
| Supports one-off callbacks as well as periodic repeating callbacks | Yes | Yes | Yes |
| Accessible across application domain boundaries | Yes | Yes | Yes |
| Supports IComponent – hostable in an IContainer | Yes | No | Yes |
Using the System.Windows.Forms.Timer is a relatively obvious choice for user interface programming. Choosing between the other two options is less obvious and generally the choice between the two is insignificant. If hosting within an IContainer is necessary then obviously System.Timers.Timer is the right choice. However, if no specific System.Timers.Timer feature is required, then I suggest choosing System.Threading.Timer by default, simply because it is a slightly lighter weight implementation.
Labels: C#