 
 Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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
Server Side Programming Articles - Page 2526 of 2650
 
 
			
			382 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
 
 
			
			479 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
 
 
			
			427 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; } . . . }
 
 
			
			798 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
 
 
			
			3K+ 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
 
 
			
			461 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
 
 
			
			1K+ 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
 
 
			
			658 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() {}
 
 
			
			569 Views
Under Composition, if the parent object is deleted, then the child object also loses its status. The composition is a special type of Aggregation and gives a part-of relationship.For example, A Car has an engine. If the car is destroyed, the engine is destroyed as well.public class Engine { . . . } public class Car { Engine eng = new Engine(); ....... }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 ... Read More
 
 
			
			218 Views
Structure In 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. To define a structure, you must use the struct statement. The struct statement defines a new data type, with more than one member for your program. Classes When you define a class, you define a blueprint for a data type. A class definition starts with the keyword class followed by the class name, and the class body enclosed by a pair of curly braces. Structure ... Read More