- 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
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
705 Views
The following are the types of expressions in C# −lvalue − An expression that is an lvalue may appear as either the left-hand or right-hand side of an assignment.rvalue − An expression that is an rvalue may appear on the right- but not left-hand side of an assignment.Variables are lvalues and hence they may appear on the left-hand side of an assignment. Numeric literals are rvalues and hence they may not be assigned and cannot appear on the left-hand side.Here is a valid C# statement −int a = 100:
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
106 Views
The ArrayCopyTo() method copies all the elements of the current one-dimensional Array to the specified one-dimensional Array starting at the specified destination Array index. The index is specified as a 32-bit integer.The CopyTo() method in C# is used to copy elements of one array to another array. In this method, you can set the starting index from where you want to copy from the source array.The following is an example showing the usage of CopyTo(, ) method of array class in C# −Exampleusing System; class Program { static void Main() { int[] arrSource = new ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
1K+ Views
To swap two numbers, work with the following logic.Set two variables for swapping −val1 = 100; val2 = 200;Now perform the following operation for swap −val1 = val1 + val2; val2 = val1 - val2; val1 = val1 - val2;The following is the code −Exampleusing System; namespace Demo { class Program { static void Main(string[] args) { int val1,val2; val1 = 100; val2 = 200; Console.WriteLine("Values before swap..."); Console.WriteLine(val1.ToString()); Console.WriteLine(val2.ToString()); val1 = val1 + val2; val2 = val1 - val2; val1 = val1 - val2; Console.WriteLine("Values after swap..."); Console.WriteLine(val1.ToString()); Console.WriteLine(val2.ToString()); Console.ReadLine(); } } }
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
3K+ Views
VirtualThe virtual keyword allows a class to be overridden. For overriding a parent class method in the child class, declare the parent class method as virtual.SealedWhen a class is declared sealed, it cannot be inherited, abstract classes cannot be declared sealed.To prevent being overridden, use the sealed in C#. When you use sealed modifiers in C# on a method, then the method loses its capabilities of overriding. The sealed method should be part of a derived class and the method must be an overridden method.public sealed override void getResult() { }NewUse the new keyword to hide the base class method ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
1K+ Views
The following are the differences between overriding and shadowing −Shadowing redefines the complete method, whereas overriding redefines only the implementation of the method.In Overriding, you can access the base class using the child class’ object overridden method.. Shadowing has cannot access the chaild class methos.Shadowing is also known as method hiding. The method of the parent class is available to the child class without using the override keyword in shadowing. The child class has its own version of the same function.Under overriding, you can define a behavior that is specific to the subclass type, which means a subclass can implement ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
OverridingUnder overriding, you can define a behavior that's specific to the subclass type, which means a subclass can implement a parent class method based on its requirement.Let us see an example of abstract classes that implements Overriding −Exampleusing System; namespace PolymorphismApplication { abstract class Shape { public abstract int area(); } class Rectangle: Shape { private int length; private int width; public Rectangle( int a = 0, int b = 0) { length = a; ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
658 Views
Let us see an example of a list collection.We have set the elements −List list = new List(); list.Add(20); list.Add(40); list.Add(60); list.Add(80);Now let’s say we need to retrieve the first element from the list. For that, set the index like this −int a = list[0];The following is an example showing how to retrieve elements from a list collection −Exampleusing System; using System.Collections.Generic; class Demo { static void Main(String[] args) { List list = new List(); list.Add(20); list.Add(40); list.Add(60); list.Add(80); ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
3K+ Views
The return statement is used to return value. When a program calls a function, the program control is transferred to the called function.The following is an example to learn about the usage of return statement in C#. Here, we are finding the average and returning the result using the return statement.double getAverage(int[] arr, int size) { int i; double avg; int sum = 0; for (i = 0; i < size; ++i) { sum += arr[i]; } avg = (double)sum / size; return avg; }Here is the complete ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
String LiteralsString literals or constants are enclosed in double quotes "" or with @"". A string contains characters that are similar to character literals: plain characters, escape sequences, and universal characters.Here are some examples of String Literals −Hello, World" "Welcome, \The following is an example showing the usage of string literals −Exampleusing System; namespace Demo { class Program { static void Main(string[] args) { // string string str1 ="Hello, World"; Console.WriteLine(str1); // Multi-line string ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
1K+ Views
Use the static method String.Format for form double string format in C#.For three decimal places −String.Format("{0:0.000}", 987.383); String.Format("{0:0.000}", 987.38); String.Format("{0:0.000}", 987.7899);For thousands separator −String.Format("{0:0,0.0}", 54567.46); String.Format("{0:0,0}", 54567.46);To format string −Exampleusing System; class Demo { public static void Main(String[] args) { Console.WriteLine("Three decimal places..."); Console.WriteLine( String.Format("{0:0.000}", 987.383)); Console.WriteLine( String.Format("{0:0.000}", 987.38)); Console.WriteLine(String.Format("{0:0.000}", 987.7899)); Console.WriteLine("Thousands Separator..."); Console.WriteLine(String.Format("{0:0,0.0}", 54567.46)); Console.WriteLine(String.Format("{0:0,0}", 54567.46)); } }