Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Programming Articles
Page 61 of 2547
What are binary literals and digit separators in C# 7.0?
C# 7.0 introduced two important enhancements to numeric literals that improve code readability and provide new ways to represent numbers: binary literals and digit separators. These features make it easier to work with binary values and large numbers in your code. Binary Literals Before C# 7.0, you could only assign decimal and hexadecimal values to variables. Binary literals allow you to directly assign binary values using the 0b or 0B prefix, making it easier to work with bit flags, masks, and other binary operations. Syntax var binaryNumber = 0b10101010; // Binary literal var binaryNumber2 ...
Read MoreWhat is the significance of NonActionAttribute in ASP .Net MVC C#?
The NonAction attribute in ASP.NET MVC is used to prevent public methods in a controller from being treated as action methods. By default, all public methods in an MVC controller are accessible via URL routing. The NonAction attribute allows you to keep methods public (for internal use within the controller or class hierarchy) while blocking direct HTTP access. Syntax Following is the syntax for applying the NonAction attribute − [NonAction] public ReturnType MethodName() { // method implementation } Why Use NonAction Attribute In ASP.NET MVC, the framework automatically treats ...
Read MoreQueue.Contains() Method in C#
The Queue.Contains() method in C# is used to determine whether a specific element exists in the Queue. It returns true if the element is found, otherwise false. This method performs a linear search through the queue elements. Syntax Following is the syntax for the Queue.Contains() method − public bool Contains(T item); Parameters item − The object to locate in the Queue. The value can be null for reference types. Return Value Returns true if the item is found in the Queue; otherwise, false. ...
Read MoreWhat are Ref locals and Ref returns in C# 7.0?
C# 7.0 introduced ref locals and ref returns, which allow methods to return references to variables instead of copies of their values. This enables direct modification of the original data through the returned reference. A ref return allows a method to return a reference to a variable, and the caller can create a ref local variable that directly references the returned memory location. Syntax Following is the syntax for declaring a ref return method − public static ref ReturnType MethodName(parameters) { return ref variable; } Following is the syntax ...
Read MoreWhat are the three segments of the default route, that is present in ASP .Net MVCnC#?
The ASP.NET MVC Routing module is responsible for mapping incoming browser requests to particular MVC controller actions. When the ASP.NET MVC application launches, it registers one or more patterns with the framework's route table to tell the routing engine what to do with any requests that match those patterns. When the routing engine receives a request at runtime, it matches that request's URL against the URL patterns registered with it and gives the response according to a pattern match. ASP.NET introduced Routing to eliminate the need of mapping each URL with a physical file. Routing enables us to define ...
Read MoreWhat are the levels at which filters can be applied in ASP .Net MVC C#?
In an ASP.NET MVC application, filters can be applied at three different levels to control the behavior of controllers and action methods. These levels determine the scope of filter application, from specific methods to the entire application. Action Method Level − Applies only to a specific action method Controller Level − Applies to all action methods within a controller Global Level − Applies to all controllers and action methods in the application Filter Application Levels Global Level Controller Level ...
Read MoreHow to use indexers in C# 8.0?
Indexers in C# allow objects to be accessed like arrays using the square bracket notation. C# 8.0 introduced the index from end operator (^) which provides a more intuitive way to access elements from the end of a collection or sequence. The ^ operator returns an index that is relative to the end of the sequence, making it the most compact and easiest way to access end elements compared to traditional methods like array.Length - 1. Syntax Following is the syntax for defining an indexer in a class − public returnType this[parameterType parameter] { ...
Read MoreWhat is the use of ChildActionOnly attribute in ASP .Net MVC C#?
The ChildActionOnly attribute in ASP.NET MVC C# restricts an action method to be accessible only through child requests from views using Html.Action() or Html.RenderAction() helpers. It prevents direct URL access to the action method, making it ideal for creating reusable partial components. Syntax Following is the syntax for using the ChildActionOnly attribute − [ChildActionOnly] public ActionResult ActionName() { // action logic return View(); } To invoke a child action from a view, use one of these helper methods − @Html.Action("ActionName", new { parameter = value }) ...
Read MoreBitConverter Class in C#
The BitConverter class in C# provides static methods to convert base data types to byte arrays and vice versa. It handles the conversion between different data types and their byte representations, making it essential for low-level data manipulation, file I/O, and network communication. Key Methods Method Description GetBytes(Boolean) Returns the specified Boolean value as a byte array. GetBytes(Char) Returns the specified Unicode character value as an array of bytes. GetBytes(Double) Returns the specified double-precision floating-point value as an array of bytes. GetBytes(Int32) Returns the specified ...
Read MoreWhat are Async Streams in C# 8.0?
C# 8.0 introduces async streams, which enable asynchronous iteration over data that is generated or retrieved asynchronously. Unlike regular streams that return all data at once, async streams produce elements one at a time as they become available. Async streams use the IAsyncEnumerable interface and allow methods to use yield return with the async modifier. You can consume async streams using await foreach loops, which asynchronously wait for each element. Syntax Following is the syntax for declaring an async stream method − static async IAsyncEnumerable MethodName() { await SomeAsyncOperation(); ...
Read More