
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

4K+ Views
A class is a blueprint that has member variables and functions in C#. This describes the behavior of an object.Let us see the syntax of a class to learn what are member variables − class class_name { // member variables variable1; variable2; ... variableN; // member methods method1(parameter_list) { // method body } method2(parameter_list) { // method body } ... methodN(parameter_list) { // method body } ... Read More

3K+ Views
A member function of a class is a function that has its definition or its prototype within the class definition similar to any other variable. It operates on an object of the class of which it is a member, and has access to all the members of a class for that object.The following is an example of a member function −public void setLength( double len ) { length = len; } public void setBreadth( double bre ) { breadth = bre; }The following is an example showing how to access member functions in C#.Example Live Demousing System; namespace ... Read More

377 Views
Each variable in C# has a specific type, which determines the size and layout of the variable's memory the range of values that can be stored within that memory and the set of operations that can be applied to the variable.To declare variables − ;Let us see an example to declare two integer variables −int a, b;Above the variable is of int type. Let us declare a variable for other types −Variable of float type.float f;Variable of double type.double d;Let us display a variable −Example Live Demousing System; using System.Collections; class Demo { static void Main() { ... Read More

229 Views
To declare member functions in interfaces in C# −public interface InterfaceName { // interface members void InterfaceMemberOne(); double InterfaceMembeTwo(); void InterfaceMemberThree() } public class ClassName: InterfaceName { void InterfaceMemberOne() { // interface member } }Above we saw our interface members are −void InterfaceMemberOne(); double InterfaceMembeTwo(); void InterfaceMemberThree()We have then used it in the class for implementing interface −public class ClassName: InterfaceName { void InterfaceMemberOne() { // interface member } }

218 Views
Interfaces 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.Let us declare interfaces −public interface ITransactions { // interface members void showTransaction(); double getAmount(); }The following is an example showing how to declare and use Interfaces in C# −Example Live Demousing System.Collections.Generic; using System.Linq; using System.Text; using System; namespace InterfaceApplication { public interface ITransactions { // interface members void showTransaction(); double getAmount(); ... Read More

3K+ Views
Keywords are reserved words predefined to the C# compiler. These keywords cannot be used as identifiers. If you want to use these keywords as identifiers, you may prefix the keyword with the @ character.In C#, some identifiers have special meaning in the context of code, such as get and set are called contextual keywords.The following table lists the reserved keywords −abstractAsbaseboolbreakbytecasecatchCharcheckedclassconstcontinuedecimaldefaultdelegatedodoubleelseenumeventexplicitExternfalsefinallyfixedfloatforforeachGotoifimplicitinin (generic modifier)intinterfaceinternalislocklongnamespacenewnullObjectoperatoroutout (generic modifier)overrideparamsprivateprotectedpublicreadonlyrefreturnsbytesealedShortsizeofstackallocstaticstringstructswitchThisthrowtruetrytypeofuintulonguncheckedunsafeushortusingvirtualvoidvolatileWhileLet us see an example of using bool reserved keyword in C# −Example Live Demousing System; using System.Collections; class Demo { static void Main() { bool[] arr = new bool[5]; ... Read More

422 Views
C# delegates are similar to pointers to functions, in C or C++. A delegate is a reference type variable that holds the reference to a method. The reference can be changed at runtime.Syntax for declaring Delegates −delegate Let us now see how to instantiate delegates in C#.Once a delegate type is declared, a delegate object must be created with the new keyword and be associated with a particular method. When creating a delegate, the argument passed to the new expression is written similar to a method call, but without the arguments to the method.public delegate void printString(string s); ... Read More

11K+ Views
To set a constant in C#, use the const keyword. Once you have initialized the constant, on changing it will lead to an error.Let’s declare and initialize a constant string −const string one= "Amit";Now you cannot modify the string one because it is set as constant.Let us see an example wherein we have three constant strings. We cannot modify it after declaring −Example Live Demousing System; class Demo { const string one= "Amit"; static void Main() { // displaying first constant string Console.WriteLine(one); const string two = ... Read More

14K+ Views
To declare and initialize a list in C#, firstly declare the list −List myList = new List()Now add elements −List myList = new List() { "one", "two", "three", };Through this, we added six elements above.The following is the complete code to declare and initialize a list in C# −Example Live Demousing System; using System.Collections.Generic; class Program { static void Main() { // Initializing collections List myList = new List() { "one", "two", "three", "four", "five", "size" }; Console.WriteLine(myList.Count); } }Output6

1K+ Views
Dictionary is a collection of keys and values in C#. Dictionary is included in the System.Collection.Generics namespace.To declare and initialize a Dictionary −IDictionary d = new Dictionary();Above, types of key and value are set while declaring a dictionary object. An int is a type of key and string is a type of value. Both will get stored in a dictionary object named d.Let us now see an example −Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main() { IDictionary d = new Dictionary(); d.Add(1, 97); ... Read More