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:
-
- How can we inject service dependency into controller C# Asp.net Core?
- ASP.NET Core injects objects of dependent classes through constructors or methods by using the built-in IoC container. The built-in container is implemented by IServiceProvider and supports constructor injection by default. Containers of types (classes) managed by built-in IoC are called services. In order for the IoC container to automatically inject our application services, we first need to register them with the IoC container. Example publicinterfaceILog{ voidinfo(stringstr);}classMyConsoleLogger:ILog{ publi
- C#.Net Tutorial 1237 2023-09-10 12:49:02
-
- How do arrays work in C#?
- An array represents a fixed number of elements of a given type. Elements are stored in contiguous blocks of memory, and you can access elements efficiently as long as you know their index. The C# syntax for declaring and initializing an array is as follows - //createastringarraytohold5languagesstring[]languages=newstring[3]; After declaring an array, you can use the square symbol on the array to fill the items in the array. languages[0]="csharp";languages[1]="visualbasic";languages[2]=&quo
- C#.Net Tutorial 1322 2023-09-10 09:41:08
-
- What are bin and obj folders in C#?
- Whenever we write C# code and build or run the solution it generates 2 folders - binobj these bins and obj have compiled code why are there 2 folders? The reason is that the compilation process goes through 2 steps: compilation and linking. During the compilation process, each individual file is compiled into a separate unit. These compiled files will later be linked into a unit, which can be a dll or an exe. The compilation phase occurs anything will be added to the obj folder the final compilation of the link stage will go into the bin folder this obj folder is used for conditional compilation or incremental compilation Ex - I have a big project which has multiple solutions and multiple files Suppose if I change any one file and build the solution then only that file
- C#.Net Tutorial 987 2023-09-10 08:01:03
-
- Keywords in C#
- Keywords are reserved words predefined by the C# compiler. These keywords cannot be used as identifiers. However, if you want to use these keywords as identifiers, you can precede the keywords with the @ character. Following are the two types of keywords in C#. reserved keyword abstract as base Booltd > break bytes case capture character selected class const continue decimal default delegate execute double other enum event td > explicit external false finally fix float forforeach go to if implicit inin (universal modifier) int Inside the interface is the Locklong namespace newnull object operator Outout (universal modifier) override parameter private protected public read-only ref return
- C#.Net Tutorial 836 2023-09-09 22:41:09
-
- How to display up to 2 decimal places or simple integer using string format in C#?
- Converts the object's values to a string according to the specified format and inserts them into another string. Each overload of the Namespace:SystemAssembly:System.Runtime.dllFormat method uses the compound formatting functionality to include zero-based indexed placeholders (called format items) in the compound format string. At run time, each format item is replaced by the string representation of the corresponding parameter in the parameter list. If the parameter value is null, the format item is replaced with String.Empty. Example classProgram{ staticvoidMain(str
- C#.Net Tutorial 1164 2023-09-09 22:01:06
-
- How to remove items from hash table collection in C#?
- Hashtable in C# is a collection of key-value pairs organized based on key hash codes. Items in a hashtable can be accessed using keys. C#'s Hashtable class is a class that implements hashtable. Using this class we can create a new hash table object with the help of the provided constructor. The Hashtable class also provides various methods with which we can perform various operations on the hash table. These operations include adding an item, checking if a specified key exists, counting the number of items, deleting items from a hash table, etc. In this article, we will discuss removing an item from a hash table collection given a specified key. How to delete items from Hashtable collection? Hashtable class
- C#.Net Tutorial 683 2023-09-09 21:01:06
-
- C# program displays the use of the GetEnvironmentVariable() method of the environment class
- In C#, the GetEnvironmentVariable() method of the Environment class is used to obtain the value of the environment variable. It is a useful method for retrieving system-wide and user-specific environment variables. In this article, we will discuss the usage of GetEnvironmentVariable() method and understand how to use it in C# program. What is the GetEnvironmentVariable() method? The GetEnvironmentVariable() method is a static method of the Environment class in C#. It takes the name of the environment variable as a string and returns the variable's value as a string. if
- C#.Net Tutorial 1441 2023-09-09 20:13:02
-
- C# program to find all substrings in a string
- Find all substrings in a string using the substring() method in C#. Assuming our string is - start,i); Console.WriteLine(substr);} Example The following is C to find all substrings in a string
- C#.Net Tutorial 832 2023-09-09 18:57:02
-
- Check if path has file extension in C#
- In the vast world of programming, C# has become a powerful, flexible, and object-oriented language that is widely used to create Windows applications, web services, and games. One of the common tasks that developers often find themselves needing to perform is checking whether a path has a file extension. In this article, we will dive into the details of how to accomplish this task in C#. Introduction to Path Handling in C# Before moving on to the topic, let’s take a brief look at path handling in C#. .NET Framework provides a Path class that comes with various static methods to perform operations on string instances containing file or directory path information. These methods save time and help prevent errors. Check file extension necessary
- C#.Net Tutorial 1515 2023-09-09 17:17:06
-
- What is the role of the IStructuralEquatable interface in C#?
- The IStructuralEquatable interface defines methods that support comparing objects for structural equality, which means that two objects are equal because they have equal values. It includes the following two methods - Sr.No Method & Description 1Equals(Object, IEqualityComparer) This method determines whether the object is structurally equal to the current instance. 2GetHashCode(IEqualityComparer) method of the hash code of the current instance. Let's see an example where I create Tuple object and use IstructuralEquatable interface: Create Tuple-vartupleOne
- C#.Net Tutorial 617 2023-09-09 17:01:08
-
- What is the purpose of StringBuilder class in C#?
- In C#, strings are immutable. This means that the string cannot be modified once created. Any modification to the string returns a new string containing the modifications, while the original string remains unchanged. stringword="aaabbbccc";stringnewWord=word.Replace('b','d');Console.WriteLine(word);//printsaaabbbcccConsole.WriteLine(newWord);//printsaaaddd
- C#.Net Tutorial 942 2023-09-09 16:53:02
-
- What is the role of the ICollection interface in C#
- In C#, the ICollection interface defines the sizes, enumerators, and synchronization methods for all non-generic collections. It is the basic interface for classes in the System.Collections namespace. The following are the attributes of the ICollection interface: Serial number attribute name and description 1Count the number of elements in the ICollection 2SyncRoot gets an object for synchronous access to the ICollection. The following are the methods of the ICollection interface: Serial number method name and description 1CopyTo(Array^,Int32) This method copies the elements of the ICollection into an array. 2GetEnumerator
- C#.Net Tutorial 820 2023-09-09 16:33:04
-
- Queue interface in C#
- A queue represents a first-in, first-out collection of objects. Use this when you need first-in-first-out access to items. When you add an item to the list, it's called enqueuing, and when you remove an item, it's called deque. Let's see an example of Queue class. To add elements, use Enqueue-Queueq=newQueue();q.Enqueue('X');q.Enqueue('Y');q.Enqueue('Z'); To remove elements, use Dequeue-/ /removeelementswhile(
- C#.Net Tutorial 699 2023-09-09 15:45:08
-
- How to run external application through C# application?
- You can use Process to run external applications from a C# application. A process is a program that runs on your computer. This can be anything from a small background task (such as a spell checker or a system event handler) to a full-blown application (such as Notepad, etc.). Each process provides the resources needed to execute the program. Every process is started by a thread, called the main thread. A process can have multiple threads in addition to the main thread. Processes heavily depend on the available system resources, while threads require minimal resources, so processes are considered heavyweight processes, while threads are called lightweight processes. The process exists in the System.Diagnostics namespace. Example usin of running notepad from C# application
- C#.Net Tutorial 1471 2023-09-09 15:05:01
-
- What is the base class for all exceptions in C#?
- The System.SystemException class is the base class for all predefined system exceptions. Some exception classes derived from System.Exception class are System.ApplicationException and System.SystemException classes. The System.ApplicationException class supports application-generated exceptions. Therefore, programmer-defined exceptions should be derived from this class. The following are the exceptions under the base class System.SystemException: Sr.No. Exception class and description 1System.IO.IOException handles I/O errors.
- C#.Net Tutorial 740 2023-09-09 13:29:14