- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 2628 Articles for Csharp
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
843 Views
GCD (Greatest Common Divisor)GCD is the largest positive integer that divides each of the integers.LCM (Least Common Multiple)LCM of two numbers is the smallest integer divisible by both the numbers.The following is an example to calculate the GCD and LCM. Here, we are calculating the LCM and GCD of 10 and 16 −Example Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { class Program { static void Main(string[] args) { int val1, val2, n1, n2, x; int resLCM, resGCD; val1 ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
405 Views
The String.Copy() method creates a new instance of String. This is same as the specified String.The following is an example of Copy() method −Example Live Demousing System; class Demo { static void Main(String[] args) { string str1 = "mark"; string str2 = "marcus"; Console.WriteLine("str1 = '{0}'", str1); Console.WriteLine("str2 = '{0}'", str2); Console.WriteLine("After using String.Copy..."); str2 = String.Copy(str1); Console.WriteLine("str1 = '{0}'", str1); Console.WriteLine("str2 = '{0}'", str2); } }Outputstr1 = 'mark' str2 = ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
1K+ Views
An interface is a class without fields or method implementation. It cannot implement the methods it defines.A class generally implements the methods defined in an interface.InterfaceInterfaces define properties, methods, and events, which are the members of the interface. Interfaces contain only the declaration of the members. It is the responsibility of the deriving class to define the members.public interface interface_name { // interface_members }ClassClass is a blueprint for a data type. This does not actually define any data, but it does define what the class name means. That is, what an object of the class consists of and what ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
379 Views
The constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals. Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. There are also enumeration constants as well.An integer literal can be a decimal, or hexadecimal constant. A prefix specifies the base or radix: 0x or 0X for hexadecimal, and there is no prefix id for decimal.150 300uA floating-point literal has an integer part, a decimal point, a fractional part, and an exponent part.3.14159 235468E-7FString ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
389 Views
String stands for System.String whereas string is an alias in C# for System.String −For examplestring str = "Welcome!";It’s not essential, but generally String is used when you work with classes.string str = String.Format("Welcome! {0}!", user);Since the string is an alias for System. String. The alias for other datatypes are −Exampleobject: System.Object string: System.String bool: System.Boolean float: System.Single double: System.Double decimal: System.Decimal byte: System.Byte sbyte: System.SByte short: System.Int16 ushort: System.UInt16 int: System.Int32 uint: System.UInt32 long: System.Int64 ulong: System.UInt64 char: System.Char
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
117 Views
To copy a collection to an array, firstly set it −List < string > list1 = new List < string > (); list1.Add("Car"); list1.Add("Bus"); list1.Add("Motorbike"); list1.Add("Train");Now declare a string array and use the CopyTo() method to copy −string[] arr = new string[20]; list1.CopyTo(arr);Let us see the complete code to copy collection to array −Exampleusing System; using System.Collections.Generic; using System.Linq; public class Demo { public static void Main() { List < string > list1 = new List < string > (); list1.Add("Car"); list1.Add("Bus"); list1.Add("Motobike"); ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
253 Views
StringReader and StringWriter derive from TextReader and TextWriterStringWriter is used for writing into a string buffer. It implements a TextWriter for writing information to a string.For StringWriter −ExampleStringWriter sWriter = new StringWriter(); while(true) { myChar = strReader.Read(); if(myChar == -1) break; convertedChar = Convert.ToChar(myChar); if(convertedChar == '.') { strWriter.Write("."); sReader.Read(); sReader.Read(); }else { sWriter.Write(convertedChar); } } }StringReader to read a string −ExampleStringBuilder sbuilder = new StringBuilder(); // append sbuilder.AppendLine("Line one characters"); sbuilder.AppendLine("Line two characters"); sbuilder.AppendLine("Line three characters"); // ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
4K+ Views
The virtual keyword is useful in modifying a method, property, indexer, or event. When you have a function defined in a class that you want to be implemented in an inherited class(es), you use virtual functions. The virtual functions could be implemented differently in different inherited class and the call to these functions will be decided at runtime.The following is a virtual functionpublic virtual int area() { }Here is an example showing how to work with virtual functions −Exampleusing System; namespace PolymorphismApplication { class Shape { protected int width, height; ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
956 Views
Non-static classes can be instantiated, whereas static classes cannot be instantiated i.e. you cannot use the new keyword to create a variable of the class type.Non-static classes can have instance method and static methods.Access the members of a static class by using the class name itself, whereas Static class is sealed.Example of non-static class −public class CalculateExample of static class −public static class Calculate
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
232 Views
The FizzBuzz problem states that −Display "Fizz" instead of the number for each multiple of 3,Display "Buzz", instead of the number for each multiple of 5.Display "FizzBuzz", instead of the number for each multiple of 5 & 3Let us see how to implement the above using C# −Exampleusing System; class Demo { static void Main(String[] args) { for(int i=1;i