- 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 27332 Articles for Server Side Programming
157 Views
To initializes a string in C# is an easy task. Let’s say you want to set a name “Amit”, for that, initialize your string as.String str1 = "Hello, World!";To compare strings, use the the following C# method.public static int Compare(string str1, string str2)To compare, if −String.Compare(str1, str2) == 0If the above is equal to 0, then both the strings are equal.The above method compares two specified string objects and returns an integer that indicates their relative position in the sort order.The following is an example that shows the comparison of one string to another.Example Live Demousing System; namespace Demo { ... Read More
145 Views
A regular expression is a pattern that could be matched against an input text. There are various categories of characters, operators, and constructs that let’s you to define regular expressions. Substitutions are used in replacement patterns. The following table lists the substitutions. Character Description Pattern Replacement pattern Input string Resulting string $number Substitutes the substring matched by group number. \b(\w+)(\s)(\w+)\b $3$2$1 "one two" "two one" ${name} Substitutes the substring matched by the named groupname. \b(?< word1>\w+)(\s)(?< word2>\w+)\b ${word2} ${word1} "one two" "two one" ... Read More
59 Views
The length property is used to gets or sets the number of elements in the BitArray.Our BitArray.BitArray arr = new BitArray( 5 );To calculate the length, use the length property.Console.WriteLine( "Length: {0}", arr.Length );You can try to run the following code to learn how to work with Length property of BitArray class.Example Live Demousing System; using System.Collections; public class Demo { public static void Main() { BitArray arr = new BitArray( 5 ); Console.WriteLine( "Count: {0}", arr.Count ); Console.WriteLine( "Length: {0}", arr.Length ); } }OutputCount: 5 Length: 5
74 Views
The IsReadOnly property of ArrayList class is useful to get a value indicating whether the ArrayList is read-only.Firstly, we have the following ArrayList.ArrayList arrList = new ArrayList();Then we have checked using the IsReadOnly Property.Console.WriteLine("myArrayList.IsReadOnly = " + arrList.IsReadOnly);The following is an example showing how to work with IsReadOnly property in ArrayList class.Example Live Demousing System; using System.Collections; class Demo { public static void Main() { ArrayList arrList = new ArrayList(); Console.WriteLine("myArrayList.IsReadOnly = " + arrList.IsReadOnly); } }OutputmyArrayList.IsReadOnly = False
8K+ Views
Use lists in C# to store elements and fetch it. Let us see an example.Example Live Demousing System; using System.Collections.Generic; public class Demo { public static void Main(string[] args) { var subjects = new List(); subjects.Add("Maths"); subjects.Add("Java"); subjects.Add("English"); subjects.Add("Science"); subjects.Add("Physics"); subjects.Add("Chemistry"); foreach (var sub in subjects) { Console.WriteLine(sub); } } }OutputMaths Java English Science Physics ChemistryNow to check whether a list is empty or not, use the Count ... Read More
90 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 = new ArrayList();Then we have checked whether ... Read More
89 Views
Hashtable class represents a collection of key-and-value pairs that are organized based on the hash code of the key. It uses the key to access the elements in the collection.Some of the commonly used methods in Hashtable class are −Sr.No.Method & Description1public virtual void Add(object key, object value);Adds an element with the specified key and value into the Hashtable.2public virtual void Clear();Removes all elements from the Hashtable.3public virtual bool ContainsKey(object key);Determines whether the Hashtable contains a specific key.4public virtual bool ContainsValue(object value);Determines whether the Hashtable contains a specific value.The following is an example showing the usage of Hashtable class in ... Read More
886 Views
The scope resolution operator in C# has a different meaning as compared with C++. In C++ the :: is used for global variables, whereas in C# it is related to namespaces.If you have a type that share an identifier in different namespace, then to identify them use the scope resolution operator.For example, to reference System.Console class, use the global namespace alias with the scope resolution operator.global::System.ConsoleExample Live Demousing myAlias = System.Collections; namespace Program { class Demo { static void Main() { myAlias::Hashtable h = new myAlias::Hashtable(); h.Add("Q", "1"); ... Read More
339 Views
Protected access specifier allows a child class to access the member variables and member functions of its base class. This way it helps in implementing inheritance. We will discuss this in more details in the inheritance chapter.The following is an example showing we have set an protected member variable in Class A.class A { protected int a2 = 87; }Now under the derived class when we will try to access the above variable from the derived class object, then it would work fine as shown below −Exampleusing System; class A { protected int a2 = 87; } class ... Read More
2K+ Views
C# and Visual C# are both the same. When you use Visual Studio for C# development, it is called Visual C# .Consider Visual C# as an implementation of C#. Microsoft Visual Studio is an IDE from Microsoft to develop programs, web app, web services, etc. The current version of Visual Studio is Visual Studio 2017, that supports .NET 3.5 to 4.7 framework. C# is a multi-paradigm programming language whose current version is C# 7.3. The following reasons make C# a widely used professional language − It is a modern, general-purpose programming language It is object oriented. It is ... Read More
To Continue Learning Please Login
Login with Google