current location:Home > Technical Articles > Backend Development > C#.Net Tutorial
- Direction:
- All web3.0 Backend Development Web Front-end Database Operation and Maintenance Development Tools PHP Framework Daily Programming WeChat Applet Common Problem Other Tech CMS Tutorial Java System Tutorial Computer Tutorials Hardware Tutorial Mobile Tutorial Software Tutorial Mobile Game Tutorial
- Classify:
-
- Hash tables and dictionaries in C#
- Hash Tables Hash tables are used when a key is needed to access an element, and useful key values can be identified. Each item in the hash table has a key/value pair. Keys are used to access items in the collection. Members in hash tables are thread-safe. If we try to find a key that doesn't exist, it will return null. Hashtable is not a generic type. Hashtable collections are slower than dictionaries because it requires boxing and unboxing. Declare Hashtable-Hashtableht=newHashtable(); Dictionary A dictionary is a collection of keys and values in C#. Dictionary is contained in the System.Collection.Generics namespace. Dicti
- C#.Net Tutorial 762 2023-09-10 23:29:08
-
- Check if given range is equal in C#
- As programmers, we often encounter situations where we need to compare two ranges in programming languages like C#. Whether we are working on a complex algorithm or a simple program, checking whether two ranges are equal is a critical task. This article will discuss the process and methods of comparing two given ranges in C#, providing a simple solution to this common problem. Understanding Scope in C# Before we proceed to solve the problem, it is crucial to have a deep understanding of scope in C# programming language. Ranges are a new feature introduced in C# 8.0 that provide syntax for working with subsets of different types of data, such as arrays, strings, and spans. You can use two dots ("..") to define the range. For example, an expression like "1..4" represents the range containing 1, 2, and 3
- C#.Net Tutorial 851 2023-09-10 23:09:02
-
- What are non-static classes in C#?
- Non-static classes can be instantiated, but static classes cannot be instantiated, that is, you cannot use the new keyword to create variables of class type. Non-static classes can have instance methods and static methods. Members of a static class are accessed using the class name itself, and static classes are sealed. Non-static class example-publicclassCalculateStatic class example-publicstaticclassCalculate
- C#.Net Tutorial 1061 2023-09-10 22:49:11
-
- Generics in C#
- Generics allow you to write classes or methods that can be used with any data type. Write a specification for a class or method and use substitution parameters for data types. When the compiler encounters a function call to a class's constructor or method, it generates code that handles the specific data type. Generics is a technology that enriches your programs by − It helps you maximize code reusability, type safety, and performance. You can create generic collection classes. The .NET Framework class library includes several new generic collection classes in the System.Collections.Generic namespace. You can use these generic collection classes instead of the collection classes in the System.Collections namespace. you can
- C#.Net Tutorial 1186 2023-09-10 21:57:11
-
- Packages in C#
- As an alternative to packages in Java, the C# language has namespaces. Packages in Java Packages are used in Java to prevent naming conflicts, control access, and make it easier to search/locate and use classes, interfaces, enumerations, annotations, etc. Namespaces in C# Namespaces are designed to provide a way to keep one set of names separate from another. A class name declared in one namespace does not conflict with the same class name declared in another namespace. A namespace definition begins with the keyword namespace, followed by the namespace name. Below shows how to use namespaces in C# - example usingSystem;namespacefirst_space{ &nb
- C#.Net Tutorial 1109 2023-09-10 21:17:02
-
- Sorting HashMap based on keys in C#
- HashMap is a Java language, not a C# language. HashMap in C# is equivalent to Dictionary and is used as a collection of key-value pairs. First, set Dictionary-Dictionary<string,int>d=newDictionary<string,int>();d.Add("soccer",1);d.Add("cricket",2);d.Add("tennis ",3);d.Add("rugby",4);Now
- C#.Net Tutorial 1237 2023-09-10 20:45:10
-
- How to use C# BinaryReader class?
- If you want to read binary information from a stream, use the BinaryReader class. The BinaryReader class is located in the System.IO namespace. The following shows using the BinaryReader class to read from a file - staticvoidWriteMe(){ using(BinaryWriterw=newBinaryWriter(File.Open("C:\abc.txt",FileMode.Create))){ w.Wr
- C#.Net Tutorial 999 2023-09-10 18:53:02
-
- Cohesion in C#
- Cohesion in C# shows the relationship between modules. It shows the functional strength of the module. The higher the cohesion, the better the program design. It is a dependency between elements inside a module such as methods and inner modules. High cohesion will allow you to reuse classes and methods. An example of high cohesion can be seen in the System.Math class, i.e. it has mathematical constants and static methods - Math.AbsMath.PIMath.Pow A class that does many things at the same time is difficult to understand and maintain. This is what we call low cohesion and should be avoided. If a class will provide email, printing, copying, etc. functionality, it will be difficult to maintain and reuse. Always try to achieve strong i.e. high cohesion in your code.
- C#.Net Tutorial 1171 2023-09-10 18:25:02
-
- What is the scope of protected member variables of a class in C#?
- Protected access specifiers allow subclasses to access member variables and member functions of their base class. This helps with inheritance. We will discuss this in more detail in the inheritance chapter. Below is an example that shows we set a protected member variable in class A. classA{ protectedinta2=87;} Now under the derived class, when we try to access the above variable from the derived class object, it will work fine as shown below - Example usingSystem;classA{ protectedinta2=87;}classB:A{&am
- C#.Net Tutorial 952 2023-09-10 18:17:08
-
- What does LINQ return when the result is null in C#?
- Language Integrated Query (LINQ) is a set of queries based on integrating query functionality directly into the C# language. You can use C# to create SQL Server databases, XML documents, ADO.NET data sets, and any collection of objects that support the IEnumerable or genericIEnumerable<T> interfaces. In Linq-to-SQL, if you try to get the first element in a query with no results, the sequence you will get does not contain any elements Error ToList returns an empty list Example classProgram{ publicstaticvoidMain(){&
- C#.Net Tutorial 1099 2023-09-10 16:57:10
-
- Double array in C#?
- Arrays of arrays in C# are called jagged arrays. To declare a jagged array, use double[][]. Now let us declare them -int[][]marks; Now, let us initialize it where marks is an array of 5 integers -int[][]marks=newint[][]{newint[]{90,95} ,newint[]{89,94},newint[]{78,87},newint[]{76,68},newint[]{98,91}};Example Let us now take a look at the sawtooth array in C# Full example and learn how to implement it − live demonstration usingSystem
- C#.Net Tutorial 1087 2023-09-10 16:53:02
-
- C# program to create a simple thread
- In order to create a thread, I created a function - publicvoidmyThread(){ for(inti=0;i<3;i++){ Console.WriteLine("MyThread"); }} Call the above function to create a thread and create a New ThreadStart delegate-Demod=newDemo();Threadthread=newThread(new
- C#.Net Tutorial 1201 2023-09-10 16:49:12
-
- How to swap two numbers in C# without using temporary variables
- To swap two numbers, you can use a third variable and perform arithmetic operators without using temporary variables. Set two variables for exchange −val1=5;val2=10; Now perform the following exchange operation-val1=val1+val2;val2=val1-val2;val1=val1-val2; Example usingSystem;namespaceDemo{ classProgram{ staticvoidMain(string[ ]args){&a
- C#.Net Tutorial 1156 2023-09-10 16:37:02
-
- The difference between ref and out in C#
- In this article, we will understand the difference between "ref" and "out" in C#. The Ref keyword requires initialization of parameters before passing them to 'ref'. There is no need to initialize parameter values before returning to the calling method. When using the 'ref' keyword, data can be passed in both directions. It is useful when the called method needs to change the value of the passed parameter. The output keyword does not require initialization of arguments before passing them to "out". The parameters need to be initialized before they are returned to the caller. When a method needs to return multiple values, it is helpful to declare parameters using the "out" keyword. When using the "out" keyword, data is passed in one direction only.
- C#.Net Tutorial 1091 2023-09-10 15:53:05
-
- What are the different ways of overloading methods in C#?
- Different ways of overloading methods are-ThedatatypesofparametersaredifferentThenumberofparametersaredifferentAn example is given below to illustrate the different data types of parameters-voidprint(inti){ Console.WriteLine("Printingint:{0}",i);}voidprint(doublef){ Console .WriteLine("
- C#.Net Tutorial 707 2023-09-10 15:13:05