- Trending Categories
- 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 34494 Articles for Programming
62 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
83 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
92 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
935 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
358 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
2K+ Views
Firstly, declare and initialize two numbers.int num1 = 35; int num2 = 55;With that, use if- else to find the minimum number.if (num1 < num2) { minNum = num1; } else { minNum = num2; }Above, we have set the minimum value to the variable minNum and printed it later on.The following is the complete example to find minimum between 2 numbers in C#.Example Live Demousing System; namespace Demo { class Program { static void Main(string[] args) { int num1 = 50; int num2 = 90; ... Read More
54 Views
A sorted list is a combination of an array and a hash table. It contains a list of items that can be accessed using a key or an index.Gets and sets the value associated with a specific key in the SortedList.You can also use the Item property to add new elements.If a key does not exist, then you can include it like.myCollection["myNonexistentKey"] = myValueIf the key already exist, then it will overwrite it with the new key and value.The following is an example to learn how to work with Item property of SorteList class in C#.Example Live Demousing System; using System.Collections; ... Read More
260 Views
The protected internal access specifier allows a class to hide its member variables and member functions from other class objects and functions, except a child class within the same application.In the below example, the derived class object can access the protected internal variable.Example Live Demousing System; class One { protected internal int a = 50; private int b; } class Two : One { public Two() { Console.WriteLine(this.a); } } class Demo { static void Main() { Two t = new Two(); // allowed since it is a derived class object t.a = 20; } }Output50