
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 2587 Articles for Csharp

114 Views
The StringBuilder.Chars[] property gets or sets the character at the specified character position in this instance.SyntaxThe syntax is as follows -public char this[int index] { get; set; }Above, the index parameter is the position of the character.ExampleLet us now see an example - Live Demousing System; using System.Text; public class Demo { public static void Main() { StringBuilder strBuilder = new StringBuilder("ghgh78hkjj"); int num = 0; for (int i = 0; i < strBuilder.Length; i++) { char c = strBuilder[i]; if (Char.IsDigit(c)) ... Read More

269 Views
The Thread.CurrentThread propertyin C# is used to get the currently running thread.SyntaxThe syntax is as follows -public static System.Threading.Thread CurrentThread { get; }ExampleLet us now see an example - Live Demousing System; using System.Threading; public class Demo { public static void Main() { Thread thread = new Thread(new ThreadStart(demo1)); ThreadPool.QueueUserWorkItem(new WaitCallback(demo2)); thread = Thread.CurrentThread; thread.Name ="Demo Thread"; Console.WriteLine("Current running Thread = "+thread.Name); Console.WriteLine("Current state of Thread = "+thread.ThreadState); Console.WriteLine("ManagedThreadId = "+thread.ManagedThreadId); } public static void demo1() { ... Read More

862 Views
Following are the properties of the String class in C# −Sr.NoProperty & Description1CharsGets the Char object at a specified position in the current String object.2LengthGets the number of characters in the current String object.ExampleLet us see an example - Live Demousing System; public class Demo { public static void Main() { string str1 = "h8b9"; string str2 = "abcdef"; Console.WriteLine("Is string1 null or empty? = "+string.IsNullOrEmpty(str1)); Console.WriteLine("Is string2 null or empty? = "+string.IsNullOrEmpty(str2)); bool val = str1 != str2; Console.WriteLine("Is str1 equal ... Read More

1K+ Views
The String.ToUpperInvariant() method in C# is used to return a copy of this String object converted to uppercase using the casing rules of the invariant culture.SyntaxThe syntax is as follows -public string ToUpperInvariant ();ExampleLet us now see an example - Live Demousing System; using System.Text; public class Demo { public static void Main(String[] args) { string str1 = "one"; string str2 = "TWO"; string str3 = "ThrEE"; Console.WriteLine("String 1 = "+str1); Console.WriteLine("String1 ToUpperInvariant = "+str1.ToUpperInvariant()); Console.WriteLine("String 2 = "+str2); ... Read More

1K+ Views
The String.ToLowerInvariant() method in C# is used to return a copy of this String object converted to lowercase using the casing rules of the invariant culture.SyntaxThe syntax is as follows -public string ToLowerInvariant ();ExampleLet us now see an example - Live Demousing System; using System.Text; public class Demo { public static void Main(String[] args) { string str1 = "Pink Floyd"; string str2 = "Ariana"; Console.WriteLine("String 1 = "+str1); Console.WriteLine("String1 ToLowerInvariant = "+str1.ToLowerInvariant()); Console.WriteLine("String 2 = "+str2); Console.WriteLine("String2 ToLowerInvariant = "+str2.ToLowerInvariant()); ... Read More

365 Views
The TimeSpan.FromTicks() method in C# is used to return a TimeSpan that represents a specified time, where the specification is in units of ticks.SyntaxThe syntax is as follows -public static TimeSpan FromTicks (long val);Above, the parameter val is the number of ticks that represent a time.ExampleLet us now see an example - Live Demousing System; public class Demo { public static void Main() { TimeSpan span1 = TimeSpan.FromTicks(18768768); TimeSpan span2 = new TimeSpan(-9, 45, 50); TimeSpan span3 = TimeSpan.FromHours(5); TimeSpan span4 = TimeSpan.FromMilliseconds(10000); TimeSpan span5 ... Read More

1K+ Views
The Object.GetHashCode() method in C# is used to serve as the default hash function.Syntaxpublic virtual int GetHashCode ();ExampleLet us now see an example - Live Demousing System; public class Demo { public static void Main() { Object ob = new Object(); String str = "Jim"; Type type1 = ob.GetType(); Type type2 = str.GetType(); Console.WriteLine("Hash Code = "+type1.GetHashCode()); Console.WriteLine("Hash Code = "+type2.GetHashCode()); } }OutputHash Code =30015890 Hash Code =21083178ExampleLet us now see another example:using System; public struct Value { private int v1; private int ... Read More

300 Views
The IsNullOrWhiteSpace() method in C# is used to indicate whether a specified string is null, empty, or consists only of white-space characters.Syntaxpublic static bool IsNullOrWhiteSpace (string val);Above, the parameter val is the string to test. Let us now see an example −ExampleLet us now see an example: Live Demousing System; public class Demo { public static void Main() { string str1 = null; string str2 = String.Empty; Console.WriteLine("Is string1 null or whitespace? = "+String.IsNullOrWhiteSpace(str1)); Console.WriteLine("Is string2 null or whitespace? = "+String.IsNullOrWhiteSpace(str2)); } }OutputThis will produce the following ... Read More

354 Views
The BitConverter.ToUInt16() method in C# is used to return a 16-bit unsigned integer converted from two bytes at a specified position in a byte array.Syntaxpublic static ushort ToUInt16 (byte[] val, int begnIndex);Above, val is the byte array, whereas begnIndex is the beginning position within val.ExampleLet us now see an example - Live Demousing System; public class Demo { public static void Main() { byte[] arr = { 10, 20, 30, 40, 50}; int count = arr.Length; Console.Write("Byte Array... "); for (int i = 0; i < count; i++) ... Read More

4K+ Views
The TimeSpan.FromSeconds() method in C# is used to return a TimeSpan that represents a specified number of seconds, where the specification is accurate to the nearest millisecond.SyntaxThe syntax is as follows -public static TimeSpan FromSeconds (double val);Above, the parameter val is the number of seconds, accurate to the nearest millisecond.ExampleLet us now see an example - Live Demousing System; public class Demo { public static void Main() { TimeSpan span1 = TimeSpan.FromSeconds(0.6768788); TimeSpan span2 = new TimeSpan(25, 15, 45); TimeSpan span3 = TimeSpan.FromHours(.4788); TimeSpan span4 = TimeSpan.FromMilliseconds(0.8787); ... Read More