- 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
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
2K+ Views
The default access for a class member in C# is private.Member variables i.e. class members are the attributes of an object (from design perspective) and they are kept private to implement encapsulation. These variables can only be accessed using the public member functions.Exampleusing System; namespace RectangleApplication { class Rectangle { //member variables private double length; private double width; public void Acceptdetails() { length = 10; width = 14; } public ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
1K+ Views
To set final for a local variable, use the read-only keyword in C#, since the implementation of the final keyword is not possible.The readonly would allow the variables to be assigned a value only once. A field marked "read-only", can only be set once during the construction of an object. It cannot be changed.Let us see an example. Below, we have set the empCount field as read-only, which once assigned cannot be changed.Exampleclass Department { readonly int empCount; Employee(int empCount) { this. empCount = empCount; } void ChangeCount() { //empCount = 150; // Compile error } }
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
108 Views
The BitArray class manages a compact array of bit values, which are represented as Booleans, where true indicates that the bit is on (1) and false indicates the bit is off (0).The following are the method of the index-based BitArray collection −Sr.No.Method & Description1public BitArray And(BitArray value);Performs the bitwise AND operation on the elements in the current BitArray against the corresponding elements in the specified BitArray.2public bool Get(int index);Gets the value of the bit at a specific position in the BitArray.3public BitArray Not();Inverts all the bit values in the current BitArray, so that elements set to true are changed to ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
303 Views
ArrayList class represents an ordered collection of an object that can be indexed individually. It is an alternative to an array.The following table lists some of the commonly used properties of the ArrayList class −Sr.NoProperty & Description1CapacityGets or sets the number of elements that the ArrayList can contain.2CountGets the number of elements actually contained in the ArrayList.3IsFixedSizeGets a value indicating whether the ArrayList has a fixed size.4IsReadOnlyGets a value indicating whether the ArrayList is read-only.5ItemGets or sets the element at the specified index.The following is an example showing how to work with ArrayList in C# and finding the capacity. The ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
737 Views
The following is the difference between implicit and explicit type conversion −Implicit Type ConversionThese conversions are performed by C# in a type-safe manner.To understand the concept, let us implicitly convert int to long.int val1 = 11000; int val2 = 35600; long sum; sum = val1 + val2;Above, we have two integer variable and when we sum it in a long variable, it won’t show an error. Since the compiler does the implicit conversion on its own.Let us print the values now.Exampleusing System; using System.IO; namespace Demo { class Program { static void Main(string[] args) ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
1K+ Views
Internal Access SpecifierInternal access specifier allows a class to expose its member variables and member functions to other functions and objects in the current assembly.Any member with internal access specifier can be accessed from any class or method defined within the application in which the member is defined.The following is an example −Exampleusing System; namespace RectangleApplication { class Rectangle { //member variables internal double length; internal double width; double GetArea() { return length * width; } ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
584 Views
Type conversion is converting one type of data to another type. Explicit conversions are done explicitly by users using the pre-defined functions and require a cast operator.Let us see an example to cast double to int −Exampleusing System; namespace Demo { class Program { static void Main(string[] args) { double a = 4563.56; int x; x = (int)a; Console.WriteLine(x); Console.ReadKey(); } } }To cast double to int, we perfomed explicit type casting −x = (int)a;
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
167 Views
C# is a modern, general-purpose, object-oriented programming language developed by Microsoft.C# is designed for Common Language Infrastructure (CLI), which consists of the executable code and runtime environment that allows the use of various high-level languages on different computer platforms and architectures.Here are the features of C# −Boolean ConditionsAutomatic Garbage CollectionStandard LibraryAssembly VersioningProperties and EventsDelegates and Events ManagementEasy-to-use GenericsIndexersConditional CompilationSimple MultithreadingLINQ and Lambda ExpressionsIntegration with Windows
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
423 Views
Boxing convert value type to an object type. Let us see an example of boxing −int x = 50; object ob = x; // boxingIn boxing, the value stored on the stack is copied to the object stored on heap memory, whereas unboxing is the opposite.Boxing is useful in storing value types in the garbage-collected heap. It is implicit conversion of a value type to the type object.Let us see an example −Exampleusing System; using System.Collections.Generic; using System.Linq; public class Demo { static void Main() { int x = 50; object ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
To copy or clone a C# list, firstly set a list −List < string > list1 = new List < string > (); list1.Add("One"); list1.Add("Two"); list1.Add("Three"); list1.Add("Four");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 a list into a one-dimensional 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("One"); list1.Add("Two"); list1.Add("Three"); ... Read More