- 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 27759 Articles for Server Side Programming
520 Views
To define the scope and visibility of a class member, use an access specifier. C# supports the following access specifiers − Public Private Protected Internal Protected internal Let us learn about them one by one. Public Access Specifier It allows a class to expose its member variables and member functions to other functions and objects. Private Access Specifier Private access specifier allows a class to hide its member variables and member functions from other functions and objects. Only functions of the same class can access its private members. Protected Access Specifier Protected access specifier allows a child class ... Read More
246 Views
Abstract classes contain abstract methods, which are implemented by the derived class. The derived classes have more specialized functionality.The following is an example showing the usage of abstract classes in C#.Example Live Demousing System; namespace Demo { 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; width = b; Console.WriteLine("Length ... Read More
118 Views
An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations.The following are the assignment operators in C#.OperatorDescriptionExample=Simple assignment operator, Assigns values from right side operands to left side operandC = A + B assigns value of A + B into C+=Add AND assignment operator, It adds right operand to the left operand and assign the result to left operandC += A is equivalent to C = C + A-=Subtract AND assignment operator, It subtracts right operand from the left operand and assign the result to left operandC -= A is equivalent to C = ... Read More
165 Views
A variable is a name given to a storage area that our programs can manipulate.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 initialize a variable, first you need to define it.int a;Now to initialize, use an equal sign followed by a constant expression.int a = 10;We used the following syntax above.variable_name = value;Let us see a simple example to work with variable in C#.Example Live Demousing System; namespace ... Read More
143 Views
All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element. To initialize an array, first you need to declare it. int[] marks; Here, int is the datatype [] specifies the size of the array Marks is the name of the array Now let us initialize the array using the new keyword. int[] marks = new int[10]; Now let us assign elements to it. marks[0] = 96; marks[1] = 90 You can also assign elements like this − int [] marks = new int[10] { 78, 67, 88, 56, 90, 77, 76, 70, 60, 70};
274 Views
Jagged array is an array of arrays. You can declare a jagged array named marks of type int as −int [][] marks;Initialize the jagged array as −int[][] marks = new int[2][]{new int[]{92, 93, 94}, new int[]{85, 66, 87, 88}};The marks is an array of two array of integers.marks[0] is an array of 3 integersmarks[1] is an array of 4 integers.The following is an example displaying how to use jagged arrays and create an array of three arrays of integers.Example Live Demousing System; namespace Demo { class Program { static void Main(string[] args) { ... Read More
218 Views
Like any other programming language, in C#, you can easily create user-defined exception. User-defined exception classes are derived from the Exception class.In the below example, the exception created is not a built-in exception.TempIsZeroExceptionYou can try to run the following code to learn how to create user defined exception in C#.Example Live Demousing System; namespace Demo { class TestTemperature { static void Main(string[] args) { Temperature temp = new Temperature(); try { temp.showTemp(); } catch(TempIsZeroException e) { ... Read More
86 Views
A Jagged array is an array of arrays. This is how you can initialize it.int[][] rank = new int[2][]{new int[]{3,2,7},new int[]{9,4,5,6}};The following is an example showing how to initialize jagged arrays in C#.Example Live Demousing System; namespace ArrayApplication { class MyArray { static void Main(string[] args) { int[][] a = new int[][]{new int[]{0,0},new int[]{1,2}, new int[]{2,4} }; int i, j; for (i = 0; i < 3; i++) { for (j = 0; j < 2; j++) { Console.WriteLine("a[{0}][{1}] = {2}", i, j, a[i][j]); } } Console.ReadKey(); } } }Outputa[0][0] = 0 a[0][1] = 0 a[1][0] = 1 a[1][1] = 2 a[2][0] = 2 a[2][1] = 4
190 Views
Custom attributes that can be used to store declarative information and can be retrieved at run-time.Let us see how to declare custom attribute.[AttributeUsage ( AttributeTargets.Class | AttributeTargets.Constructor | AttributeTargets.Field | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = true)] public class DeBugInfo : System.AttributeFor our example, let us construct a custom attribute named DeBugInfo, which stores the information obtained by debugging any program.The DeBugInfo class has three private properties for storing the first three information and a public property for storing the message. Hence the bug number, developer's name, and date of review are the positional parameters of the DeBugInfo class and the ... Read More
To Continue Learning Please Login
Login with Google