- 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
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
191 Views
The IsFixedSize property of ArrayList class is used to get a value indicating whether the ArrayList has a fixed size.The following is an example stating the usage of isFixedSize property −Example Live Demousing System; using System.Collections; class Demo { public static void Main() { ArrayList arrList = new ArrayList(); Console.WriteLine("Adding some numbers:"); arrList.Add(45); arrList.Add(78); Console.WriteLine(arrList.Count); Console.WriteLine("myArrayList.IsFixedSize = " + arrList.IsFixedSize); } }OutputAdding some numbers: 2 myArrayList.IsFixedSize = FalseAbove we have added an array list −ArrayList arrList ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
258 Views
The final block is used to execute a given set of statements, whether an exception is thrown or not thrown. For example, if you open a file, it must be closed whether an exception is raised or not.The error handling blocks are implemented using the try, catch, and finally keywords.ExampleYou can try to run the following code to implement finally statement −using System; namespace ErrorHandlingApplication { class DivNumbers { int result; DivNumbers() { result = 0; } public void division(int ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
130 Views
Enum is Enumeration to store a set of named constants like a year, product, month, season, etc.The default value of Enum constants starts from 0 and increments. It has a fixed set of constants and can be traversed easily.Let us see an example.We have set the enum like this −public enum Vehicle { Car, Bus, Truck }The following is the complete example −Example Live Demousing System; public class Demo { public enum Vehicle { Car, Bus, Truck } public static void Main() { int a = (int)Vehicle.Car; int b = (int)Vehicle.Bus; ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
313 Views
Encapsulation in C# prevents access to implementation details. Implement Encapsulation in C# using access specifiers.The following are the access specifiers supported by C# −PublicPrivateProtectedInternalProtected internalEncapsulation can be understood by taking an example of private access specifier that allows a class to hide its member variables and member functions from other functions and objects.In the following example we have length and width as variables assigned private access specifier −Example Live Demousing System; namespace RectangleApplication { class Rectangle { private double length; private double width; public void Acceptdetails() { ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
263 Views
Aggregation is a directional relation between objects in C#. It is the relationship between objects.For example, Employee and AddressAn Employee is associated with a single Department, whereas a Department can have more than one employee. Let us see an example of Employee and Address −public class Address { . . . } public class Employee { private Address addr; public Employee (Address addr) { this.addr = addr; } . . . }
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
527 Views
Like any other programming language, in C#, you can easily create a user-defined exception. User-defined exception classes are derived from the Exception class. Custom exceptions are what we call user-defined exceptions.In the below example, the exception created is not a built-in exception; it is a custom exception −TempIsZeroExceptionYou can try to run the following code to learn how to create a user-defined exception in C# −Example Live Demousing System; namespace Demo { class TestTemperature { static void Main(string[] args) { Temperature temp = new Temperature(); try { ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
2K+ Views
The User defined data types in C# are structures and enumeration.StructureIn C#, a structure is a value type data type. It helps you to make a single variable hold related data of various data types. The struct keyword is used for creating a structure.The C# structures have the following features −Structures can have methods, fields, indexers, properties, operator methods, and events.Structures can have defined constructors, but not destructors. However, you cannot define a default constructor for a structure. The default constructor is automatically defined and cannot be changed.Unlike classes, structures cannot inherit other structures or classes.Structures cannot be used as ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
249 Views
The following are the unary operators in C# −+ - ! ~ ++ -- (type)* & sizeofLet us learn about the sizeof operator. The sizeof returns the size of a data type.Let’s say you need to find the size of int datatype −sizeof(int)For double datatype −sizeof(double)Let us see the complete example to find the size of various datatypes −Example Live Demousing System; namespace Demo { class Program { static void Main(string[] args) { Console.WriteLine("The size of int is {0}", sizeof(int)); Console.WriteLine("The size of int is ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
770 Views
The mechanism of linking a function with an object during compile time is called early binding. It is also called static binding. C# provides two techniques to implement static polymorphism i.e Function overloading and Operator overloading.Let us learn about Function Overloading with an example −You can have multiple definitions for the same function name in the same scope. The definition of the function must differ from each other by the types and/or the number of arguments in the argument list. You cannot overload function declarations that differ only by return type.The following is the complete example −Example Live Demousing System; ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
407 Views
In Dynamic binding, the compiler will not do type checking at compile time. At runtime, the checking is done.Use it to avoid the restriction of anonymous types to one method. This is only because the type name is visible only to the compiler; therefore, you cannot declare it as the return value of a method.Let us see an example −public dynamic GetAnonymousType() { return new { StudentName = "Jack", Subject = "Maths", }; }Above, the method is set to be dynamic, that would mean the compiler won’t do type checking at compile time −public dynamic GetAnonymousType() {}