current location:Home > Technical Articles > Backend Development > C#.Net Tutorial

  • C# program to determine whether a number is divisible by 2
    C# program to determine whether a number is divisible by 2
    If the remainder of dividing this number by 2 is 0, then it is divisible by 2. Assuming our number is 5, we will use the following if-else to check it - //checkingifthenumberisdivisibleby2ornotif(num%2==0){ Console.WriteLine("Divisibleby2");}else{ Console.WriteLine("Notdivisibleby2") ;} Example below is
    C#.Net Tutorial 1318 2023-09-05 22:53:06
  • What are AddSingleton, AddScoped and Add Transient C# Asp.net Core?
    What are AddSingleton, AddScoped and Add Transient C# Asp.net Core?
    There are three ways to register dependencies in Startup.cs. ie. AddSingleton, AddScoped and AddTransient. Adding a Singleton When we register a type as a singleton, only one instance is available throughout the process. applicationandforevery request. It is similar to having a static object. The instance is created for the first request and the same is available throughout the application and every subsequent request. pub
    C#.Net Tutorial 1583 2023-09-05 22:21:17
  • C# program to reverse string
    C# program to reverse string
    Our example string is - myStr="Tom"; To reverse the string, first find the length of the string −//findstringlengthintlen; len=myStr.Length-1; Now, use a while loop until the length is greater than 0 - while (len>=0){ rev=rev+myStr[len]; len--;} Example You can try running the following code to reverse a string in C#. Live demonstration usingSystem;cl
    C#.Net Tutorial 1324 2023-09-05 19:09:03
  • C# program to check whether a path is a directory or a file
    C# program to check whether a path is a directory or a file
    Introduction Let us learn how to write a C# program to check whether a path is a directory or a file. A directory, also called a folder, is a location on your computer where files can be saved. In addition to files, directories also contain other directories or shortcuts. A file is a collection of data on a drive that has a unique identifier and directory path. When a file is opened for viewing or writing, it is converted to a stream. A stream is simply a sequence of bytes traversing a communication path. Files and Directories Files are real data files, while directories are repositories where logical files are placed on the system. To handle files and directories, the common language runtime (CLR) has classes File, FileInfo, Directory, and DirectoryInfo in the System.IO namespace. for
    C#.Net Tutorial 625 2023-09-05 17:49:02
  • How to catch out of memory exception in C#?
    How to catch out of memory exception in C#?
    System.OutOfMemoryException occurs when the CLR cannot allocate enough memory required. System.OutOfMemoryException inherits from the System.SystemException class. Set the string - stringStudentName="Tom"; stringStudentSubject="Maths"; Now you need to initialize with the allocated capacity, i.e. the length of the initial value - StringBuildersBuilder=newStringBuilder(Stud
    C#.Net Tutorial 1064 2023-09-05 16:09:07
  • What is binary serialization and deserialization in C# and how to implement binary serialization in C#?
    What is binary serialization and deserialization in C# and how to implement binary serialization in C#?
    Converting an object into an unreadable binary format is called binary serialization. Converting a binary format back to a readable format is called deserialization? To implement binary serialization in C# we have to use the library System.Runtime.Serialization.Formatters.BinaryAssembly. Create an object of BinaryFormatter class and use the serialize method inside the class. ExampleSerializeanObjecttoBinary[Serializable]publicclassDemo{ publicstr
    C#.Net Tutorial 1391 2023-09-05 15:53:02
  • Collections in C#
    Collections in C#
    A collection in C# is a HashSet. HashSet in C# eliminates duplicate strings or elements in an array. In C#, it is an optimized set collection declaration HashSet-varh=newHashSet<string>(arr1); Above, we have set the declared array arr1 in the HashSet. Now set it on an array to remove duplicate words - string[]arr2=h.ToArray(); Let us see an example of removing duplicate strings using C# HashSet. Here, we have repeated elements - example usingSystem;usingSystem.Colle
    C#.Net Tutorial 1492 2023-09-05 15:37:02
  • What is a jagged array in C#?
    What is a jagged array in C#?
    A jagged array is an array of arrays in C#. You can declare and initialize it - int[][]rank=newint[1][]{newint[]{5,3,1}}; The following example shows how to use jagged array in C# - Example usingSystem;namespaceProgram { classDemo{ staticvoidMain(string[]args){ &a
    C#.Net Tutorial 1312 2023-09-05 13:52:12
  • What is the AddRange method in C# List?
    What is the AddRange method in C# List?
    The AddRange method in a list adds the entire collection of elements. Let's see an example - First, set up a list in C# and add elements - List<int>list=newList<int>();list.Add(100);list.Add(200);list.Add(300 );list.Add(400);Now set the array of elements to be added to the list -//arrayof4elementsint[]arr=newint[4];arr[0]=500;arr[1]=600;arr[2] =700;arr[3]=800;Use Ad
    C#.Net Tutorial 1758 2023-09-05 12:41:02
  • What is the proxy design pattern and how to implement it in C#?
    What is the proxy design pattern and how to implement it in C#?
    The proxy pattern provides a proxy or placeholder object to control access to a different object. Proxy objects are used in the same way as their containing objects. Participant Subject defines a public interface for RealSubject and Proxy so that Proxy can be used wherever RealSubject needs it. RealSubject defines the specific object represented by the Proxy. The proxy maintains a reference to the real subject and controls access to it. It must implement the same interface as RealSubject so that the two can be used interchangeably. If you've ever needed to change the behavior of an existing object without actually changing that object's definition, the proxy pattern allows you to do just that. Furthermore, this is
    C#.Net Tutorial 1302 2023-09-05 12:21:10
  • C# program to check if HashTable collection is empty
    C# program to check if HashTable collection is empty
    A Hashtable collection in C# is a collection of key-value pairs organized according to the hash code of the key. The hash code is calculated using the hash code function. Each element in a hash table is a key-value pair with a unique key. The key must also be non-null. Values ​​can be empty and repeated. In this article, we will discuss how to check if a hash table collection is empty. How to check if hash table collection is empty? The class that implements a hash table collection in C# is the Hashtable class. We can check if the hash table collection is empty by counting the number of elements present in the hash table. For this we can use the "Count" property of the Hashtable class, which returns the number of elements in the hash table. So if the Count property returns 0, it means the hash table is empty
    C#.Net Tutorial 767 2023-09-05 11:17:02
  • C# program to find client's IP address
    C# program to find client's IP address
    First find the host name using Dns.GetHostName() method in C# - StringhostName=string.Empty;hostName=Dns.GetHostName();Console.WriteLine("Hostname:"+hostName); Now, use IPHostEntry.AddressList property to get IP address-IPHostEntrymyIP=Dns.GetHostEntry(hostName);IPAddress[]address=myIP.Address
    C#.Net Tutorial 1162 2023-09-05 11:09:09
  • How to add items to ArrayList in C#?
    How to add items to ArrayList in C#?
    ArrayList is a non-generic collection in C# that can be dynamically resized. Let us see how to initialize ArrayList in C# - ArrayListarr=newArrayList(); Add items to array list - ArrayListarr1=newArrayList(); arr1.Add(30); arr1.Add(70); Let us see how to use C# Complete example implementing ArrayList. Here we have two array lists. The second array list is appended to the first list. ExampleusingSystem;usingSystem.Collections;publiccla
    C#.Net Tutorial 987 2023-09-05 09:53:02
  • What is the difference between overriding and hiding in C#?
    What is the difference between overriding and hiding in C#?
    Here is the difference between overriding and hiding - hiding redefines the complete method, while overriding only redefines the implementation of the method. In an override, you can access the base class using the object overridden methods of the subclass. Shadow cannot access subclass methods. Shadowing is also called method hiding. The methods of the parent class can be used by the subclass without using the override keyword in the shadow. Subclasses have their own versions of the same functions. Under override, you can define behavior that is specific to the subclass type, which means that the subclass can implement the parent class methods as per its requirements.
    C#.Net Tutorial 1236 2023-09-04 23:49:02
  • How is encapsulation implemented in C#?
    How is encapsulation implemented in C#?
    Encapsulation is achieved through the use of access specifiers. Access specifiers define the scope and visibility of class members. C# supports the following access specifiers: Public, Private, Protected, Internal, ProtectedInternal, etc. Encapsulation can be understood through private access specifier, which allows a class to hide its member variables and functions from other functions and objects. In the example below, we have length and width as variables assigned private access specifiers - example usingSystem;namespaceRectangleApplication{ classRectan
    C#.Net Tutorial 1328 2023-09-04 23:17:02

Tool Recommendations

jQuery enterprise message form contact code

jQuery enterprise message form contact code is a simple and practical enterprise message form and contact us introduction page code.
form button
2024-02-29

HTML5 MP3 music box playback effects

HTML5 MP3 music box playback special effect is an mp3 music player based on HTML5 css3 to create cute music box emoticons and click the switch button.

HTML5 cool particle animation navigation menu special effects

HTML5 cool particle animation navigation menu special effect is a special effect that changes color when the navigation menu is hovered by the mouse.
Menu navigation
2024-02-29

jQuery visual form drag and drop editing code

jQuery visual form drag and drop editing code is a visual form based on jQuery and bootstrap framework.
form button
2024-02-29

Organic fruit and vegetable supplier web template Bootstrap5

An organic fruit and vegetable supplier web template-Bootstrap5
Bootstrap template
2023-02-03

Bootstrap3 multifunctional data information background management responsive web page template-Novus

Bootstrap3 multifunctional data information background management responsive web page template-Novus
backend template
2023-02-02

Real estate resource service platform web page template Bootstrap5

Real estate resource service platform web page template Bootstrap5
Bootstrap template
2023-02-02

Simple resume information web template Bootstrap4

Simple resume information web template Bootstrap4
Bootstrap template
2023-02-02

Cute summer elements vector material (EPS PNG)

This is a cute summer element vector material, including the sun, sun hat, coconut tree, bikini, airplane, watermelon, ice cream, ice cream, cold drink, swimming ring, flip-flops, pineapple, conch, shell, starfish, crab, Lemons, sunscreen, sunglasses, etc., the materials are provided in EPS and PNG formats, including JPG previews.
PNG material
2024-05-09

Four red 2023 graduation badges vector material (AI EPS PNG)

This is a red 2023 graduation badge vector material, four in total, available in AI, EPS and PNG formats, including JPG preview.
PNG material
2024-02-29

Singing bird and cart filled with flowers design spring banner vector material (AI EPS)

This is a spring banner vector material designed with singing birds and a cart full of flowers. It is available in AI and EPS formats, including JPG preview.
banner picture
2024-02-29

Golden graduation cap vector material (EPS PNG)

This is a golden graduation cap vector material, available in EPS and PNG formats, including JPG preview.
PNG material
2024-02-27

Home Decor Cleaning and Repair Service Company Website Template

Home Decoration Cleaning and Maintenance Service Company Website Template is a website template download suitable for promotional websites that provide home decoration, cleaning, maintenance and other service organizations. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-05-09

Fresh color personal resume guide page template

Fresh color matching personal job application resume guide page template is a personal job search resume work display guide page web template download suitable for fresh color matching style. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-02-29

Designer Creative Job Resume Web Template

Designer Creative Job Resume Web Template is a downloadable web template for personal job resume display suitable for various designer positions. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-02-28

Modern engineering construction company website template

The modern engineering and construction company website template is a downloadable website template suitable for promotion of the engineering and construction service industry. Tip: This template calls the Google font library, and the page may open slowly.
Front-end template
2024-02-28