
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

1K+ Views
To retrieve the attributes of a file, use the FileAttributes Eumeration. It has various members like compressed, directory, hidden, etc. To check if a file is hidden, use the hidden member name. If the FileAttributes.hidden is set that would mean the file is hidden. Firstly, get the path to find the attributes. FileAttributes attributes = File.GetAttributes(path); If the following is set, that would mean the file is now hidden using the hidden member name. File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden); Console.WriteLine("The {0} file is hidden.", path);

108 Views
Use the IsReadOnly property to get a value indicating whether the SortedList is read-only or not.You can try to run the following code to implement IsReadOnly property in C#.Here, we have set the SortedList first.SortedList s = new SortedList();Added elements.s.Add("S001", "Jack"); s.Add("S002", "Henry");Now check for IsReadOnly.Console.WriteLine("IsReadOnly = " + s.IsReadOnly);The following is the complete code.Example Live Demousing System; using System.Collections; namespace Demo { class Program { static void Main(string[] args) { SortedList s = new SortedList(); s.Add("S001", "Jack"); s.Add("S002", "Henry"); Console.WriteLine("IsReadOnly ... Read More

468 Views
Character constantsCharacter literals are enclosed in single quotes. For example, 'x' and can be stored in a simple variable of char type. A character literal can be a plain character (such as 'x'), an escape sequence (such as '\t'), or a universal character (such as '\u02C0').Certain characters in C# are preceded by a backslash. They have special meaning and they are used to represent like newline () or tab (\t).Example Live Demousing System; namespace Demo { class MyApplication { static void Main(string[] args) { Console.WriteLine("Welcome\t to the website"); Console.ReadLine(); ... Read More

600 Views
C# has many operators that work on the left-right and righ-left associativity. Chanining depends on the left-to-right associativity on operators with same precedence. Operator precedence determines the grouping of terms in an expression. This affects evaluation of an expression. Certain operators have higher precedence than others do; for example, the multiplication operator has higher precedence than the addition operator. The operators with the highest precedence appear at the top of the table, those with the lowest appear at the bottom. Within an expression, higher precedence operators are evaluated first. To check whether a string is null or not, you can ... Read More

3K+ Views
To draw an ellipse, use the drawEllipse() method in C# that belong to the Graphics object. It has a pen object as well as a rectangle object. You need windows form to draw shapes in C#. Set graphics object. Graphics g = this.CreateGraphics(); Now, the pen object. Pen p = new Pen(new SolidBrush(Color.Red), 15); The following is the rectangle object. Rectangle r = new Rectangle(120, 60, 180, 180); Now use the drawEllipse() method with the graphics object and add both the objects in it to draw an ellipse. s.DrawEllipse(p, r);

104 Views
Use the IsFixedSize property in C# to get a value indicating whether the SortedList has a fixed size.The following is an example showing SorteList with the usage of IsFixedSize property.Example Live Demousing System; using System.Collections; namespace Demo { class Program { static void Main(string[] args) { SortedList s = new SortedList(); s.Add("S1", "Maths"); s.Add("S2", "Science"); s.Add("S3", "English"); s.Add("S4", "Economics"); Console.WriteLine("IsFixedSize = " + s.IsFixedSize); } } }OutputIsFixedSize = FalseWe ... Read More

17K+ Views
Using the DateTime nullable type, you can assign the null literal to the DateTime type.A nullable DateTime is specified using the following question mark syntax.DateTime?The following is the code to implement Nullable Datetime.Example Live Demousing System; class Program { static void Main() { DateTime? dt = null; DateFunc(dt); dt = DateTime.Now; DateFunc(dt); dt = null; Console.WriteLine(dt.GetValueOrDefault()); } static void DateFunc(DateTime? dt) { if (dt.HasValue) { Console.WriteLine(dt.Value); } else { Console.WriteLine(0); } } }Output0 9/17/2018 8:27:07 AM 1/1/0001 12:00:00 AM

1K+ Views
A class can be derived from more than one class or interface, which means that it can inherit data and functions from multiple base classes or interfaces.The derived class inherits the base class member variables and member methods. Therefore, the super class object should be created before the subclass is created. You can give instructions for superclass initialization in the member initialization list.Here you can see object is created for the inherited class.Example Live Demousing System; namespace Demo { class Rectangle { protected double length; protected double width; public Rectangle(double l, ... Read More

2K+ Views
For secure random numbers, use the RNGCryptoServiceProvider Class. It implements a cryptographic Random Number Generator.Using the same class, we have found some random values using the following −using (RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider()) { byte[] val = new byte[6]; crypto.GetBytes(val); randomvalue = BitConverter.ToInt32(val, 1); }To generate random secure numbers, you can try to run the following code.Example Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Security.Cryptography; public class Demo { public static void Main(string[] args) { for (int i = 0; i

2K+ Views
A nested class is a class declared in another enclosing class. It is a member of its enclosing class and the members of an enclosing class have no access to members of a nested class.Let us see an example code snippet of nested classes in C#.Exampleclass One { public int num1; public class Two { public int num2; } } class Demo { static void Main() { One a = new One(); a.num1++; One.Two ab = new One.Two(); ab.num2++; } ... Read More