<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Shahzad</title>
    <description>The latest articles on DEV Community by Shahzad (@shahzad111111).</description>
    <link>https://dev.to/shahzad111111</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1405858%2Ffc0285a1-56b5-4fa4-abc2-41444cc6c3c7.png</url>
      <title>DEV Community: Shahzad</title>
      <link>https://dev.to/shahzad111111</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shahzad111111"/>
    <language>en</language>
    <item>
      <title>What is C# History?</title>
      <dc:creator>Shahzad</dc:creator>
      <pubDate>Fri, 09 Jan 2026 09:59:49 +0000</pubDate>
      <link>https://dev.to/shahzad111111/what-is-c-history-1nb3</link>
      <guid>https://dev.to/shahzad111111/what-is-c-history-1nb3</guid>
      <description>&lt;h2&gt;
  
  
  What is history of C#?
&lt;/h2&gt;

&lt;p&gt;C# (pronounced "C Sharp") is a programming language that is latest, flexible. It is made by Microsoft. C# is an object-oriented programming language that support four main pillar of OOP Abstraction, Encapsulation, Inheritance, Polymorphism. It run on .NET Framework. It's history start from late 1990s.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important Overview of the History of C#&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Late 1990s - Project Cool:&lt;/strong&gt;&lt;br&gt;
when Microsoft initiated "Project Cool in the the late 1990s the development of C# can be traced back. For Windows application development there was a need of a project that aimed to create a new, modern, and safer language.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. 1999 - C# Announcement:&lt;/strong&gt;&lt;br&gt;
The July 1999 was a year when C# was officially introduced to the public by Microsoft, at the Professional Developers Conference (PDC). For the Microsoft's .NET initiative It was seen as a key component and was designed to provide a join platform for building Windows applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Early 2000s - .NET Framework:&lt;/strong&gt;&lt;br&gt;
As part of the .NET Framework C# was released in 2002.This was made for building and running Windows and web applications as a comprehensive platform. For multiple programming languages, including C# the .NET Framework provided a common runtime environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Cross-Platform Development (C# 9.0 and later):&lt;/strong&gt;&lt;br&gt;
The support of cross-platform development was started with the invention of .NET 5.0 and later, We can create web and desktop base application and software with C# and many other languages that run on various operating system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. 2002 - First Official Release:&lt;/strong&gt;&lt;br&gt;
C# 1.0 was officially released in January 2002 as part of Visual Studio .NET. This marked the first stable version of the language.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. 2005 - C# 2.0:&lt;/strong&gt;&lt;br&gt;
C# 2.0 introduced several enhancements, including generics, anonymous methods, nullable value types, and more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. 2008 - C# 3.0:&lt;/strong&gt;&lt;br&gt;
C# 3.0 brought significant language improvements, such as lambda expressions, extension methods, and the LINQ (Language-Integrated Query) framework.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. 2010 - C# 4.0:&lt;/strong&gt;&lt;br&gt;
C# 4.0 added dynamic typing, optional and named parameters, and COM interop improvements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9. 2012 - C# 5.0:&lt;/strong&gt;&lt;br&gt;
C# 5.0 introduced asynchronous programming support with the async and await keywords.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10. 2015 - C# 6.0:&lt;/strong&gt;&lt;br&gt;
C# 6.0 included features like null-conditional operators, expression-bodied members, and string interpolation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;11. 2017 - C# 7.0:&lt;/strong&gt;&lt;br&gt;
C# 7.0 introduced pattern matching, local functions, and tuples, among other language enhancements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;12. 2018 - C# 7.1:&lt;/strong&gt;&lt;br&gt;
C# 7.1 was a minor update, adding features like async main methods and tuple projection initializers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;13. 2019 - C# 8.0:&lt;/strong&gt;&lt;br&gt;
C# 8.0 brought significant language improvements, including nullable reference types, ranges, and default interface methods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;14. 2020 - .NET 5.0:&lt;/strong&gt;&lt;br&gt;
Init-Only setters property gives us the flexibility to set the value of a property by using the object initializer as well the property is also immutable. The Main() method and surrounding namespace and program class details are no longer required. The purpose of Init-only properties is to allow assignment only in the object initializer or the constructor for your class. In a field declaration, readonly indicates that assignment to the field can only occur as part of the declaration or in a constructor in the same class. A readonly field can be assigned and reassigned multiple times within the field declaration and constructor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;15. 2021 - .NET 6.0:&lt;/strong&gt;&lt;br&gt;
It allows you to simplify a struct definition to a single line. A global using directive imports a namespace for your whole application instead of a single file. These global directives can be added either by adding a item to the project file, or by adding the global using directive to a code file. File scoped namespaces use a less verbose format for the typical case of files containing only one namespace. The file scoped namespace format is namespace X.Y.Z; (note the semicolon and lack of braces).Allow property subpatterns to reference nested members. Specifies that the method or property will ensure that the listed field and property members have values that aren't null.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;15. 2022 - .NET 7.0:&lt;/strong&gt;&lt;br&gt;
.NET 7.0, released in November 2022, is a unified, high-performance, cross-platform development platform for building cloud, web, desktop, mobile, and IoT apps. It includes performance improvements, minimal APIs enhancements, and better support for containerization and cloud-native development. It is a Standard-Term Support (STS) release, supported for 18 months. .NET 7 continues the vision of unifying .NET Core and .NET Framework into a single platform.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;15. 2023 - .NET 8.0:&lt;/strong&gt;&lt;br&gt;
.NET 8.0, released in November 2023, is a Long-Term Support (LTS) release with support until November 2026. It brings major performance improvements, native AOT (Ahead-of-Time) compilation for more app types, and enhanced cloud-native and container support. .NET 8 also improves Blazor, minimal APIs, and machine learning (ML.NET). It continues the unification of .NET for cross-platform development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;15. 2024 - .NET 9.0:&lt;/strong&gt;&lt;br&gt;
.NET 9.0, expected in November 2024, is a Standard-Term Support (STS) release focused on performance, cloud-native optimization, and developer productivity. It enhances Native AOT, introduces new C# 13 features, and improves support for WASM, containers, and cross-platform apps. .NET 9 continues the evolution of unified .NET with tooling and runtime improvements across all workloads.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;15. 2025 - .NET 10.0:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;.NET 10.0 was officially released around November 11 / 12, 2025 at .NET Conf and is a Long Term Support (LTS) release supported through November 2028. &lt;/p&gt;

&lt;p&gt;It focuses on major performance improvements across the runtime and compilers, making apps faster with better JIT inlining, memory handling, and hardware acceleration. &lt;/p&gt;

&lt;p&gt;The release deeply integrates AI-centric capabilities, including the new Microsoft Agent Framework for building intelligent applications. &lt;/p&gt;

&lt;p&gt;It includes updates to languages like C# 14 and F# 10, improvements to ASP.NET Core, MAUI, Blazor, and expanded support for modern workloads including enhanced cryptography and networking. &lt;/p&gt;

&lt;p&gt;Overall, .NET 10 aims to be a unified, secure, and high-performance platform for modern cloud, web, mobile, and AI applications&lt;/p&gt;

&lt;p&gt;For reading complete above tutorial please visit following link :&amp;nbsp;&lt;a href="https://c-sharptutorial.com/basic/history-in-csharp" rel="noopener noreferrer"&gt;C# History&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For more such type of tutrials please visit this site:&amp;nbsp;&lt;a href="https://c-sharptutorial.com" rel="noopener noreferrer"&gt;C-Sharp Tutorial&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading&lt;/p&gt;

</description>
      <category>programming</category>
      <category>csharp</category>
    </item>
    <item>
      <title>Top 83 C# Advance Interview Questions and Answers With Examples [2026]</title>
      <dc:creator>Shahzad</dc:creator>
      <pubDate>Thu, 25 Dec 2025 10:12:48 +0000</pubDate>
      <link>https://dev.to/shahzad111111/top-83-c-advance-interview-questions-and-answers-with-examples-2026-5841</link>
      <guid>https://dev.to/shahzad111111/top-83-c-advance-interview-questions-and-answers-with-examples-2026-5841</guid>
      <description>&lt;h2&gt;
  
  
  1. What is C# Generics?
&lt;/h2&gt;

&lt;p&gt;C# Generics allow us to create a single class or method, interfaces, methods, and delegates that can be used with different types of data. Generics enable you to write more flexible and reusable code by allowing you to create components that can work with any data type.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. What are C# Partial Classes and Methods?
&lt;/h2&gt;

&lt;p&gt;In Partial classes we can split a class, a struct, a method, or an interface into multiple parts with the same class name into .cs file and with partial keyword . Partial class was first introduced in C# 2.0. We use a specifc keyword to making partial class that is called partial.&lt;/p&gt;

&lt;p&gt;Partial classes are very useful for organizing large classes, becasue whenever you will have large classes, the code inside these large class will be mized up and it will have lack of clean oorginization. so keeping clean organization of code we can split a larage class into small parital classes.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. What is Anonymous Method in C#?
&lt;/h2&gt;

&lt;p&gt;An anonymous method is a method which doesn’t contain any name which is introduced in C# 2.0. In C#, an anonymous method allows you to define a method inline without explicitly declaring a separate named method. It's particularly useful when you need a method as a delegate parameter, such as for event handling or LINQ queries.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// An Anonymous Method

delegate(parameters) {
// method body

};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. What is Nullable Types in C#?
&lt;/h2&gt;

&lt;p&gt;In C#, nullable types are a feature introduced to allow value types (such as int, double, bool, etc.) to have a value of null, in addition to their normal range of values. This is particularly useful in scenarios where you need to represent the absence of a value or where a value might legitimately be undefined.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example With Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;double? pi = 3.14;
char? letter = 'a';
int m2 = 10;
int? m = m2;
bool? flag = null;
// An array of a nullable value type:

int?[] arr = new int?[10];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. What is Iterators in C#?
&lt;/h2&gt;

&lt;p&gt;In C#, iterators provide a convenient way to iterate over collections or sequences of data. They allow you to define custom iteration behavior for your classes, similar to how you use foreach with built-in collections like arrays or lists.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example With Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public IEnumerable&amp;lt;int&amp;gt; MyIteratorMethod()
{
// yield return statements
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  6. What is Covariance and Contravariance in C#?
&lt;/h2&gt;

&lt;p&gt;In C#, covariance and contravariance enable implicit reference conversions for generic type parameters. Covariance (using out) allows a method to return a more derived type than specified by the generic parameter.&lt;/p&gt;

&lt;p&gt;Contravariance (using in) allows a method to accept parameters of less derived types. These concepts are commonly used with delegates and interfaces to increase flexibility in type assignments.&lt;/p&gt;

&lt;p&gt;In C#, "more derived type" and "less derived type" refer to the relationship between classes in an inheritance hierarchy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Derived Type:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;More derived type : A child class that inherits from another base class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Less derived type : A base class that is inherited by another child class.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Derived Type: Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Less derived (base class)

class Food { }
// More derived (inherits from Food)

class Fruit : Food { }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;In above example&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;More derived type : Fruit is a more derived type than Food. Fruit can be derived from Food class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Less derived type : Food is a less derived type than Fruit. Food can not be derived from any other base class.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  7. What is Anonymous Types in C#?
&lt;/h2&gt;

&lt;p&gt;In C#, anonymous types are a way to create objects without explicitly defining a class. They are defined using the var keyword and an object initializer. Anonymous types are often used in LINQ queries to hold temporary, read-only data. Their properties are inferred by the compiler and cannot be modified after creation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var person = new { Name = "John", Age = 30 };
// Output: John

Console.WriteLine(person.Name);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  8. What is Query Expression in C#?
&lt;/h2&gt;

&lt;p&gt;A query is a set of instructions that describes what data to retrieve from a given data source (or sources) and what shape and organization the returned data should have. A query is distinct from the results that it produces.&lt;/p&gt;

&lt;p&gt;Generally, the source data is organized logically as a sequence of elements of the same kind. For example, an SQL database table contains a sequence of rows. In an XML file, there's a "sequence" of XML elements (although XML elements are organized hierarchically in a tree structure). An in-memory collection contains a sequence of objects&lt;/p&gt;

&lt;h2&gt;
  
  
  9. What is Lambda Expressions in C#?
&lt;/h2&gt;

&lt;p&gt;In C#, lambda expressions are anonymous functions that can contain expressions or statements and are used to create delegates or expression tree types. They provide a concise way to represent inline methods, typically written as (parameters) =&amp;gt; expression. For example: (x, y) =&amp;gt; x + y&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of Lambda Expression&lt;/strong&gt;&lt;br&gt;
There are two types of lambda expression.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Expression Lambdas&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Statement Lambdas&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;1. C# Expression Lambdas:&lt;/strong&gt;&lt;br&gt;
Lambdas expression contain a single expression and return a value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax of Expression Lambdas&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Syntax of Expression Lambdas

(parameters) =&amp;gt; expression
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example of Expression Lambdas&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Example of Expression Lambdas

(x, y) =&amp;gt; x + y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. C# Statement Lambdas:&lt;/strong&gt;&lt;br&gt;
These can contain multiple statements enclosed in braces {} and can include control flow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax of Statement Lambdas&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Syntax of Statement Lambdas

(parameters) =&amp;gt; { statements }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example of Statement Lambdas&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Example of Statement Lambdas

Action&amp;lt;string&amp;gt; greet =name =&amp;gt;
{
string greeting = $"Hello {name}!";
Console.WriteLine(greeting);
};
greet("World");
// Output:

// Hello World!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  10. What is Extension Methods in C#?
&lt;/h2&gt;

&lt;p&gt;In C#, extension methods allow you to "add" new methods to existing types without modifying their source code or creating a new derived type. This is particularly useful when working with types you don’t have control over, like .NET framework classes or third-party libraries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example With Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static class ExtensionClass
{
public static return MethodName(this Type type, ...)
{
// Method body

}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  11. What is Object initializers in C#?
&lt;/h2&gt;

&lt;p&gt;An object initializer in C# is a syntax feature that lets you create and initialize an object in a single statement, without having to explicitly call a constructor followed by separate property assignments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ClassName obj = new ClassName { Property1 = value1, Property2 = value2 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  12. What is Collection Initializer in C#?
&lt;/h2&gt;

&lt;p&gt;A collection initializer in C# lets you create and populate a collection (like a List, Dictionary, etc.) in a single statement, making the code more concise and readable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C# Collection Initializer Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var collection = new CollectionType { item1, item2, item3 };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  13. What is Dynamic Binding in C#?
&lt;/h2&gt;

&lt;p&gt;Dynamic binding in C# refers to resolving method calls or member access at runtime instead of compile time. This is achieved using the dynamic keyword introduced in C# 4.0.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example With Sytax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// fruitName is interpreted as string at runtime

dynamic fruitName = "Mango";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  14. What is Named Optional Parameters in C#?
&lt;/h2&gt;

&lt;p&gt;C# supports two useful method features: named parameters and optional parameters, which improve code clarity and flexibility when calling methods.&lt;/p&gt;

&lt;p&gt;Named parameters gives us a facility to specify arguments by parameter name, not just by position.This improves readability and allows skipping the need to remember parameter order.&lt;/p&gt;

&lt;p&gt;Optional parameters allow you to leave out arguments when calling a method.You assign default values in the method definition.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C# Named Parameters : Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Using named parameters

FruitInfo(name: "Apple", price: 0.86);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  15. What is Covariance And Contravariance in Generics in C#?
&lt;/h2&gt;

&lt;p&gt;Covariance and contravariance allow flexibility in assigning generic types when working with inheritance hierarchies — especially with interfaces and delegates.&lt;/p&gt;

&lt;p&gt;Covariance allows a method to return a more derived type than originally specified.&lt;/p&gt;

&lt;p&gt;Contravariance allows a method to accept arguments of a less derived type.&lt;/p&gt;

&lt;h2&gt;
  
  
  16. What is C# Await Async in C#?
&lt;/h2&gt;

&lt;p&gt;In C#, async and await are used to perform asynchronous programming, allowing your program to run tasks without blocking the main thread, such as I/O operations, web requests, or file reads.&lt;/p&gt;

&lt;p&gt;async modifier: - Marks a method as asynchronous and allows use of await inside.&lt;/p&gt;

&lt;p&gt;await keyword: - Tells the compiler to pause execution of the method until the awaited task completes, then resume from that point.&lt;/p&gt;

&lt;p&gt;Imagine you're baking a cake. While the cake is in the oven (a time-consuming operation), instead of standing there doing nothing, you go wash dishes or clean the kitchen. You continue once the oven timer beeps. It is real life example for Await Async.&lt;/p&gt;

&lt;h2&gt;
  
  
  17. What is Caller Info Attributes in C#?
&lt;/h2&gt;

&lt;p&gt;Caller Info Attributes in C# provide metadata about the caller of a method — such as the file name, line number, and member name — at compile time. These are especially useful for logging, debugging, and diagnostics.&lt;/p&gt;

&lt;h2&gt;
  
  
  18. What is C# Static Import in C#?
&lt;/h2&gt;

&lt;p&gt;Static import in C# (introduced in C# 6.0) allows you to import static members (methods, properties, constants, etc.) from a class so you can use them without qualifying them with the class name.&lt;/p&gt;

&lt;p&gt;To simplify code and improve readability, especially when you're using many static members from a utility or helper class (e.g., Math, Console, custom utilities).&lt;/p&gt;

&lt;p&gt;You often use Math class functions like Sqrt, Pow, or PI. Instead of writing Math.Sqrt() and Math.PI every time, you can import them statically. It is real life example of C# static import.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C# Static Import Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using System;
// Static import of Math class

using static System.Math;
// Static import of Console class

using static System.Console;
class CSharpProgram
{
static void Main(string[] args)
{
double radius = 5;
// No need to write Math.PI or Math.Pow

double area = PI * Pow(radius, 2);
// No need to write Console.WriteLine

WriteLine($"Area of circle: {area}");
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;Area of circle: 78.53981633974483&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  19. What is Exception Filters in C#?
&lt;/h2&gt;

&lt;p&gt;Exception filters in C# allow you to conditionally catch exceptions based on a logical expression — without handling the exception unless the condition is true.&lt;/p&gt;

&lt;p&gt;Why we use Exception Filters in C# becasue it was Introduced in C# 6.0, exception filters improve control and clarity when dealing with different error conditions.&lt;/p&gt;

&lt;p&gt;You're catching falling apples. You only catch the red apples, not the green ones.Similarly, an exception filter lets you catch specific types or conditions of exceptions without swallowing everything. It is real life example of Exception Filters&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C# Exception Filters : Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Exception Filters Syntax

catch (ExceptionType ex) when (condition)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  20. What is Auto Property Initializers in C#?
&lt;/h2&gt;

&lt;p&gt;In C#, Auto-Property Initializers let you assign default values to auto-implemented properties directly at the point of declaration, without needing to use a constructor.&lt;/p&gt;

&lt;p&gt;Why Use Auto Property Initializers in C# becasue it simplifies class definitions by removing boilerplate code.It was introduced in C# 6.0&lt;/p&gt;

&lt;p&gt;Imagine filling out a registration form where some fields already have pre-filled values (e.g., "Country = USA"). You only change them if needed. Similarly, auto-property initializers pre-fill property values. It is real life example of Auto Property Initializers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C# Auto Property Initializers : Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Auto Property Initializers Syntax

public DataType PropertyName { get; set; } = defaultValue;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  21. What is Expression-Bodied Members in C#?
&lt;/h2&gt;

&lt;p&gt;Expression-bodied members in C# allow you to define methods, properties, constructors, etc., using a single-line expression with the =&amp;gt; (lambda-style) syntax instead of full block syntax { ... }.&lt;/p&gt;

&lt;p&gt;It was introduced in C# 6.0, and extended in later versions (e.g., C# 7+)&lt;/p&gt;

&lt;p&gt;Why use Expression-Bodied Members in C# becasue to simplify code that contains short logic — making it cleaner and more readable.&lt;/p&gt;

&lt;p&gt;If someone asks you, “What's 2 + 2?” you don’t write an essay — you just say “4.”Expression-bodied members work the same way for short, obvious operations. It is real life example of Expression-Bodied Members.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C# Expression-Bodied Members : Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Expression-Bodied Members Syntax

member =&amp;gt; expression;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  22. What is Null Propagation Operator in C#?
&lt;/h2&gt;

&lt;p&gt;The null propagation operator (?.) in C# lets you safely access members (properties, methods, indexers, etc.) of an object that might be null, without throwing a NullReferenceException.&lt;/p&gt;

&lt;p&gt;If the object is null, the whole expression returns null instead of crashing.&lt;/p&gt;

&lt;h2&gt;
  
  
  23. What is String Interpolation in C#?
&lt;/h2&gt;

&lt;p&gt;String interpolation in C# allows you to insert variables or expressions directly into a string using the $ symbol and curly braces {}. It's a cleaner, more readable alternative to string.Format() or string concatenation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C# String Interpolation : Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// String Interpolation Syntax

$"Text with {variable} and {expression}"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  24. What is Nameof Operator in C#?
&lt;/h2&gt;

&lt;p&gt;The nameof operator in C# returns the name of a variable, type, or member as a string, without hardcoding the name manually. It helps make your code safer and easier to refactor, especially in logging, exceptions, and validation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C# Nameof Operator : Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//C# Nameof Operator Syntax

nameof(identifier)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  25. What is Tuple Deconstruction in C#?
&lt;/h2&gt;

&lt;p&gt;The tuples feature provides concise syntax to group multiple data elements in a lightweight data structure. The following example shows how you can declare a tuple variable, initialize it, and access its data members.&lt;/p&gt;

&lt;p&gt;A tuple is a lightweight data structure that groups multiple values into one object. You can use the Tuple class or the newer (T1, T2, ...) syntax introduced in C# 7.0&lt;/p&gt;

&lt;p&gt;Deconstruction allows you to unpack the tuple into individual variables in a very readable way.&lt;/p&gt;

&lt;p&gt;Imagine a method that calculates the total price and the estimated delivery time for an online order. It needs to return both values. It is real life example of Tuple Deconstruction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C# Tuple : Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//C# Tuple Syntax

(ValueType1 name1, ValueType2 name2) tupleName = (value1, value2);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  26. What is Pattern Matching in C#?
&lt;/h2&gt;

&lt;p&gt;Pattern matching in C# is a feature that allows you to check the shape (type and properties) of data and conditionally extract values from it — in a safe, readable, and expressive way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C# is Pattern: Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//C# is Pattern Syntax

if (obj is Type varName)
{
/* use varName here */

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  27. What is Local Functions in C#?
&lt;/h2&gt;

&lt;p&gt;Local functions in C# are functions defined inside another method. They're useful when a helper method is only needed within the context of that method, keeping code organized and scoped locally.&lt;/p&gt;

&lt;p&gt;You're calculating the total bill at a restaurant. You need a small function to calculate tax — but it’s only used inside the billing method, so you don’t want to make it a separate method in the class. It is real life example of Local Functions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C# Local Functions Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using System;
class CSharpProgram
{
static void Main(string[] args)
{
double subtotal = 100.0;
double total = CalculateTotal(subtotal);
Console.WriteLine($"Total bill: ${total}");
}
static double CalculateTotal(double amount)
{
// Local function defined inside the method

double CalculateTax(double value)
{
// 10% tax

return value * 0.1;

}
return amount + CalculateTax(amount);
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  28. What is Ref Locals And Ref Returns in C#?
&lt;/h2&gt;

&lt;p&gt;Ref locals allow you to create a reference to a variable or array element, so that when you modify the reference, the original value changes directly.They are useful when you want to work with large data efficiently or change data in-place without copying. A ref return allows a method to return a reference to a variable (instead of a copy). This means the caller can directly modify the original value stored in the calling scope (like an array element, field, or variable).&lt;/p&gt;

&lt;h2&gt;
  
  
  29. What is Discards Variable in C#?
&lt;/h2&gt;

&lt;p&gt;A discard in C# is represented by the underscore _. It’s used when you don't care about a value — such as when you're ignoring part of a tuple, a return value, or an out parameter. It’s a way to make your code cleaner and clearer, showing that a value is intentionally unused.&lt;/p&gt;

&lt;p&gt;You try parsing a string to a number to validate it, but you don’t care about the parsed value — just whether it succeeds. It is real life example of Discards Variable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C# Discards Method Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// C# Discard return value

_ = SomeMethod();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  30. What is Binary Literals And Digit Separators in C#?
&lt;/h2&gt;

&lt;p&gt;Binary literals was introduced in C# 7.0, binary literals use the prefix 0b to represent numbers in binary format.In Digit separators you can use underscores (_) to visually separate digits in numeric literals, making them easier to read.It Works in binary, decimal, and hexadecimal number.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Binary Literals : Syntax&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// C# Binary Literals Syntax

0b01010101
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;For reading complete above tutorial please visit following link :&lt;/strong&gt; &lt;a href="https://c-sharptutorial.com/Interview/advance-csharp-interview-questions" rel="noopener noreferrer"&gt;c# advanced interview questions&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For more such type of tutrials please visit this site:&lt;/strong&gt; &lt;a href="https://c-sharptutorial.com/" rel="noopener noreferrer"&gt;C-Sharp Tutorial&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Thanks for reading.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>programming</category>
      <category>softwaredevelopment</category>
      <category>interview</category>
    </item>
    <item>
      <title>Top 50+ C# Interview Questions and Answers With Examples [2025]</title>
      <dc:creator>Shahzad</dc:creator>
      <pubDate>Thu, 25 Dec 2025 07:17:41 +0000</pubDate>
      <link>https://dev.to/shahzad111111/c-interview-questions-562o</link>
      <guid>https://dev.to/shahzad111111/c-interview-questions-562o</guid>
      <description>&lt;h2&gt;
  
  
  What is C# history?
&lt;/h2&gt;

&lt;p&gt;C# (pronounced "C Sharp") is a programming language that is latest, flexible. It is made by Microsoft. C# is an object-oriented programming language that support four main pillar of OOP Abstraction, Encapsulation, Inheritance, Polymorphism. It run on .NET Framework. It's history start from late 1990s.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. What are C# main feactures?
&lt;/h2&gt;

&lt;p&gt;C#, which is also called C Sharp, is a programming language that was made by Anders Hjelsberg. C# combines the computational power of C++ and the ease of Visual Basic, Microsoft’s event-driven programming language and environment. C is the building block from which C# is made. Microsoft came out with C# in the year 2000. It was made to meet the growing demand for online applications that Visual Basic (VB) and C++ can’t meet. Because of this, so The programmers who know how to work with C and C++ can quickly learn how to use C# and by using C# you can make website and desktop application very easily in versatile way and you can also use web services that make capable two or more systems to exchange data over network. Data are exchanged either using XML or JSON.&lt;/p&gt;

&lt;p&gt;Here, below are some main features of C#&lt;/p&gt;

&lt;p&gt;1 - Object-Oriented&lt;/p&gt;

&lt;p&gt;2 - Type Safety&lt;/p&gt;

&lt;p&gt;3 - Garbage Collection&lt;/p&gt;

&lt;p&gt;4 - Cross-Platform Development (C# 9.0 and later)&lt;/p&gt;

&lt;p&gt;5 - Managed Code&lt;/p&gt;

&lt;p&gt;6 - Rich Standard Library&lt;/p&gt;

&lt;h2&gt;
  
  
  3. What is Dot Net Framework?
&lt;/h2&gt;

&lt;p&gt;Dot NET Framework is a software development framework for making and running applications on Windows. Dot Framework is part of the .NET platform and provide us a collection of technologies for building website, software and apps for Linux, macOS, Windows, iOS, Android. It has a common runtime (CLR - Common Language Runtime) and a large number of class library that supports more then 60 programming languages, including C#. .NET Framework is the original implementation of .NET. It supports running websites, services, desktop apps, and more on Windows.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. What is Common Language Runtime (CLR)?
&lt;/h2&gt;

&lt;p&gt;The management of the execution of.NET applications is the responsibility of the CLR. It provides a range of services including garbage collection, exception handling and security. It is a program execution engine that loads and executes the program. It converts the program into native code. It acts as an interface between the framework and operating system. It does exception handling, memory management, and garbage collection. Moreover, it provides security, type-safety, interoperability, and portablility. A list of CLR components are given below:&lt;/p&gt;

&lt;h2&gt;
  
  
  5. What is Base Class Library (BCL)?
&lt;/h2&gt;

&lt;p&gt;The BCL contains a set of classes, interfaces and value types that provide the essential functionality for your.NET applications. It's about collections, files, networking, security, and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  6.What are keywords in C#?
&lt;/h2&gt;

&lt;p&gt;Keywords that we use in C# programming language have special meanings and these Keywords as they are special in programming so we cannot used it as identifiers specially like variable name, method name, and class names in you code.&lt;/p&gt;

&lt;p&gt;We define vairable with string keyword in C#.&lt;/p&gt;

&lt;p&gt;Here, in below example&lt;/p&gt;

&lt;p&gt;string - a keyword&lt;/p&gt;

&lt;p&gt;fruitName - variable name&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Define a string variable

string fruitName;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  7. What are operators in C#?
&lt;/h2&gt;

&lt;p&gt;In C#, operators are symbols or keywords used to perform various operations on data, such as arithmetic calculations, logical comparisons, and assignments.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. What are data types in C#?
&lt;/h2&gt;

&lt;p&gt;The behavior of storing data in variable are described with data types. It is responsibility of a specific data type to store a specific value. For example number values are store in integer type data types.&lt;/p&gt;

&lt;p&gt;Primitive Data Types:&lt;/p&gt;

&lt;p&gt;Integral Types:&lt;/p&gt;

&lt;p&gt;Floating-Point Types:&lt;/p&gt;

&lt;p&gt;Character Type:&lt;/p&gt;

&lt;p&gt;Boolean Type:&lt;/p&gt;

&lt;p&gt;Reference Data Types:&lt;/p&gt;

&lt;p&gt;String Type:&lt;/p&gt;

&lt;h2&gt;
  
  
  9. What are Variables in C#?
&lt;/h2&gt;

&lt;p&gt;Variables in C# are used for storing data this data can be in shape of number, characters, text and true, false and decimal. for example for example: int - stores integers (whole numbers), without decimals, such as 123 or -123. double - stores floating point numbers, with decimals, such as 19.99 or -19.99 and char store character like 'A' and string store text like "Apple Red!"&lt;/p&gt;

&lt;h2&gt;
  
  
  10. What is break statement in C#?
&lt;/h2&gt;

&lt;p&gt;In C#, the break statement is a control flow statement that is used to exit a loop or switch statement prematurely. It allows you to terminate the execution of the innermost loop or switch block and continue with the code immediately following the loop or switch statement&lt;/p&gt;

&lt;h2&gt;
  
  
  11. What is continue statement in C#?
&lt;/h2&gt;

&lt;p&gt;The continue statement is used to skip the current iteration of a loop. This continue statement usually we used with for, while, do-while statement. when continue statement skipped the current iteration then control goes to next iteration. It is typically used within loops to control the flow of execution based on a specific condition.&lt;/p&gt;

&lt;h2&gt;
  
  
  12. What is goto statement in C#?
&lt;/h2&gt;

&lt;p&gt;In C#, the goto statement allows you to transfer control to a labeled statement within the same method or block of code.&lt;/p&gt;

&lt;h2&gt;
  
  
  13. What is function in C
&lt;/h2&gt;

&lt;p&gt;In C#, a function is a block of code that performs a specific task and can be called from other parts of your program. Functions are a fundamental concept in C# and are often referred to as methods.&lt;/p&gt;

&lt;p&gt;Functions in C# are known as methods and are defined within a class or struct. They can have parameters, which are variables passed into the method, and they can return a value or be void (returning no value).&lt;/p&gt;

&lt;h2&gt;
  
  
  14. What is ref parameter in C
&lt;/h2&gt;

&lt;p&gt;In C#, the ref keyword is used to indicate that a method parameter is a reference parameter.&lt;/p&gt;

&lt;p&gt;Reference parameters allow you to pass a reference to a variable as an argument to a method, rather than passing a copy of the variable's value. This means that any changes made to the parameter within the method will affect the original variable outside the method as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  15. What is out parameter in C
&lt;/h2&gt;

&lt;p&gt;The out keyword is used to declare output parameters in method or function signatures. The output parameter is a parameter that is used to return multiple values from a method. The output parameters are used to pass data out of a method. But a normal function is used for passing the data inside function.&lt;/p&gt;

&lt;h2&gt;
  
  
  16. What is in parameter in C
&lt;/h2&gt;

&lt;p&gt;in is used to state that the parameter passed cannot be modified by the method. An any attempt to modified will give you compile-time error. in parameter was introduced in C# 7.2.&lt;/p&gt;

&lt;h2&gt;
  
  
  17. What is array in C
&lt;/h2&gt;

&lt;p&gt;Array is such type of collection that have the capability to stores a fixed-sized elements of the same data type. But have the difference with mixed data types like array List that can store mixed data types.&lt;/p&gt;

&lt;p&gt;In array you can store multiple values of the same data type for example you can store multiple values of int data type of same variable and similarly In array you can also access multiple values of the same type under a single variable name.&lt;/p&gt;

&lt;p&gt;Suppose we need to record the 7 different numbers. Instead of creating 7 separate variables, we can simply create an array:&lt;/p&gt;

&lt;h2&gt;
  
  
  18.Can we pass array to function?
&lt;/h2&gt;

&lt;p&gt;A function can receive a parameter. Similarly a function can also receive an array. We can pass an array as parameter to function. In this activity, when we pass an array to a function we actually passes a reference to the array. we give permission to a function that it can access and can modify the elements of the array.&lt;/p&gt;

&lt;h2&gt;
  
  
  19.What is multidimensional array in C#?
&lt;/h2&gt;

&lt;p&gt;If you have date in the shape of tables, matrices, grids then multidimensional arrays are useful. We declared the multidimensional array by adding commas in the square brackets. We can declare two-dimensional, three-dimensional, four-dimensional array in such a way respectively [,], [, ,], [, , ,].&lt;/p&gt;

&lt;h2&gt;
  
  
  20. What is jagged array in C#?
&lt;/h2&gt;

&lt;p&gt;In C#, a jagged array is an array of arrays. Unlike rectangular (multidimensional) arrays, jagged arrays allow each element of the outer array to be an array of different lengths. This flexibility makes jagged arrays useful for representing irregular data structures where the inner arrays can have varying sizes. Each row (dimension) has a different length or size in jagged arrays, but in a multidimensional array, each row (dimension) has fixed or the same length because because each row is essentially a separate array.&lt;/p&gt;

&lt;h2&gt;
  
  
  21. What are params in C#?
&lt;/h2&gt;

&lt;p&gt;In C#, "params" is a keyword used in method parameter to indicate that a method can accept a different number of parameters of the same type. This feature is often used when you want to create methods that can accept an undecided number of parameters.&lt;/p&gt;

&lt;h2&gt;
  
  
  22. What are the types of classes in C#?
&lt;/h2&gt;

&lt;p&gt;Here, below are types of classes in C#&lt;/p&gt;

&lt;p&gt;1 - Abstract class&lt;/p&gt;

&lt;p&gt;2 - Partial class&lt;/p&gt;

&lt;p&gt;3 - Sealed class&lt;/p&gt;

&lt;p&gt;4 - Static class&lt;/p&gt;

&lt;h2&gt;
  
  
  23. What is class in C#?
&lt;/h2&gt;

&lt;p&gt;A class is basic pillar of OOP that is called when instance of a class is created. A class can have fields, properties, method, constructor and destructor etc. When we create an instance of class. This instance of class is used to access of fields, methods, properties, constructor (constructor can zero argument or multiple argument) and destructor. A class is reference type and stores in heap.&lt;/p&gt;

&lt;h2&gt;
  
  
  24. What is constructor in C#?
&lt;/h2&gt;

&lt;p&gt;Constructor is special method that called when object/instance of class is created&lt;/p&gt;

&lt;h2&gt;
  
  
  25. What is destructor in C#?
&lt;/h2&gt;

&lt;p&gt;Destructor is also a special method that called when object/instance of class is destroyed.&lt;/p&gt;

&lt;h2&gt;
  
  
  26. What is static class in C#?
&lt;/h2&gt;

&lt;p&gt;In C#, a static is a keyward that is used with fields, methods, properties and classes when we make these members static they are globally accessble in all over the application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rules for Making Static Class&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here we have defined some rules of making static class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Declaration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A static class must be declared using the static keyword.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Static Members:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All members (methods, properties, fields) of a static class must also be static.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instantiation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Static classes cannot be instantiated; you cannot create an object of a static class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instance Members:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Static classes cannot contain instance members (non-static fields or methods).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Static Methods:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A static class can contain static methods, which can be called without creating an instance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Static Constructor:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A static class can have a static constructor for initialization purposes, which is called automatically before any static members are accessed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Accessibility:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Static classes are sealed class and therefore, cannot be inherited. A static class cannot inherit from other classes.&lt;/p&gt;

&lt;h2&gt;
  
  
  27. What is static method in C#?
&lt;/h2&gt;

&lt;p&gt;A Static method is also accessible all over the application globally. When we want that a method will be accessible in all over the application with creating the instance of class then we make it static.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Rules for making Static Methods&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Here we have defined some rules of making static method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Accessibility Modifiers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Static methods can have access modifiers (e.g., public, private) that determine their visibility outside the class&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inheritance:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Static methods are not polymorphic. You cannot override a static method in a derived class; however, you can hide it by declaring a static method with the same name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No this Keyword:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Inside a static method, you cannot use the this keyword since there is no instance context.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Calling:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can call static methods using the class name, or from other static methods within the same class without needing to specify the class name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No Access to Instance Members:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Static methods cannot access instance variables or instance methods directly. They can only interact with static members.&lt;/p&gt;
&lt;h2&gt;
  
  
  28. What is static constructor in C#?
&lt;/h2&gt;

&lt;p&gt;A non-static class can contain a zero-argument static constructor. It can be defined with the static keyword and without access modifiers like public, private, and protected.&lt;/p&gt;

&lt;p&gt;Note:The static constructor gets called when you create an instance for the first time.&lt;/p&gt;

&lt;p&gt;Static Constructor Example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// First static constructor and then instance constructor called

Fruit sw1 = new Fruit();

// only instance constructor called

Fruit sw2 = new Fruit();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Rules for making Static Constructors&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here we have defined some rules of making static constructor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Declaration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A static constructor is defined with the static keyword and does not have any parameters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Initialization Timing:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is called automatically before any static members are accessed or any instance of the class is created.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Single Invocation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The static constructor is called only once per type, regardless of how many instances of the class are created.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No Parameters:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;They cannot take parameters, which means they can’t be overloaded.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inheritance:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If a derived class has a static constructor, the base class's static constructor is called first.&lt;/p&gt;

&lt;h2&gt;
  
  
  29. What is struct in C#?
&lt;/h2&gt;

&lt;p&gt;A struct a value type and it store it's data in stack. Classes are reference type and it store it's data in heap. The structs are usually used for small data structures. The structs are specially used when we don't need features of classes like inheritance.&lt;/p&gt;

&lt;p&gt;Suppose we want to store the name and color of a fruit. We can create two variables: name and color and store value. However, suppose we want to store the same information of multiple fruit.&lt;/p&gt;

&lt;p&gt;In this case, creating variables for an individual fruit might be a tedious task. To overcome this we can create a struct that stores name and color. Now, this struct can be used for every fruit.&lt;/p&gt;

&lt;h2&gt;
  
  
  30. What is enum in C#?
&lt;/h2&gt;

&lt;p&gt;The enum is also called enumeration. It is a value type. Enum is used to define the set of named constant values&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For reading complete above tutorial please visit following link :_ &lt;a href="https://c-sharptutorial.com/Interview/basic-csharp-interview-questions" rel="noopener noreferrer"&gt;c# interview questions&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For more such type of tutrials please visit this site: &lt;a href="https://c-sharptutorial.com" rel="noopener noreferrer"&gt;C-Sharp Tutorial&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Thanks for reading.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>programming</category>
      <category>interview</category>
    </item>
    <item>
      <title>Html Introduction</title>
      <dc:creator>Shahzad</dc:creator>
      <pubDate>Thu, 25 Dec 2025 06:38:43 +0000</pubDate>
      <link>https://dev.to/shahzad111111/html-introduction-4hb7</link>
      <guid>https://dev.to/shahzad111111/html-introduction-4hb7</guid>
      <description>&lt;p&gt;&lt;strong&gt;HTML Tutorial&lt;/strong&gt;&lt;br&gt;
HTML (HyperText Markup Language) is the standard language used to create and structure content on the web. It uses tags to define elements like headings, paragraphs, links, and images, allowing browsers to display web pages correctly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Was a Problem for Invention of HTML?&lt;/strong&gt;&lt;br&gt;
Before HTML, there was no standard way to share and link documents across different systems on the internet. Researchers and scientists struggled to access and connect information stored in various formats and locations. Tim Berners-Lee saw this problem while working at CERN, where data was difficult to retrieve and share between different computers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Was a Solution?&lt;/strong&gt;&lt;br&gt;
The solution was HTML — a simple markup language that allowed content to be structured in a consistent way and linked using hyperlinks. Along with HTML, Berners-Lee also created the URL and HTTP protocol, forming the foundation of the World Wide Web and making global information sharing easy and standardized.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is HTML?&lt;/strong&gt;&lt;br&gt;
HTML stands for HyperText Markup Language.&lt;/p&gt;

&lt;p&gt;It is used to create the structure of web pages.&lt;/p&gt;

&lt;p&gt;It is not a programming language, but a markup language.&lt;/p&gt;

&lt;p&gt;Browsers read HTML to display text, images, links, and layout.&lt;/p&gt;

&lt;p&gt;HTML files have .html or .htm extensions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why is HTML?&lt;/strong&gt;&lt;br&gt;
Builds Web Pages: HTML is the foundation for creating all websites.&lt;/p&gt;

&lt;p&gt;Defines Structure: It organizes content using headings, paragraphs, lists, tables, etc.&lt;/p&gt;

&lt;p&gt;Browser Support: All modern web browsers understand and render HTML.&lt;/p&gt;

&lt;p&gt;Easy to Learn: HTML is simple and beginner-friendly.&lt;/p&gt;

&lt;p&gt;Works with Other Tech: HTML works seamlessly with CSS and JavaScript.&lt;/p&gt;

&lt;p&gt;SEO Friendly: Proper HTML helps search engines understand and rank your content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Who Invented HTML?&lt;/strong&gt;&lt;br&gt;
Inventor: HTML was invented by Tim Berners-Lee.&lt;/p&gt;

&lt;p&gt;Year of Invention: It was developed in 1991.&lt;/p&gt;

&lt;p&gt;Purpose: Created to share and link scientific documents through the internet.&lt;/p&gt;

&lt;p&gt;Organization: Tim Berners-Lee worked at CERN (European Organization for Nuclear Research) when he invented it.&lt;/p&gt;

&lt;p&gt;First Version: The first version of HTML had only 18 tags.&lt;/p&gt;

&lt;p&gt;Legacy: HTML became the core technology of the World Wide Web.&lt;/p&gt;

&lt;p&gt;For more useful tutorials please click here : &lt;a href="https://c-sharptutorial.com/home/html-tutorial" rel="noopener noreferrer"&gt;Html Tutorial&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>ref Parameter in C#</title>
      <dc:creator>Shahzad</dc:creator>
      <pubDate>Wed, 03 Apr 2024 17:30:38 +0000</pubDate>
      <link>https://dev.to/shahzad111111/ref-parameter-in-c-29m4</link>
      <guid>https://dev.to/shahzad111111/ref-parameter-in-c-29m4</guid>
      <description>&lt;p&gt;In C#, the ref keyword is used to indicate that a method parameter is a reference parameter. Reference parameters allow you to pass a reference to a variable as an argument to a method, rather than passing a copy of the variable's value. This means that any changes made to the parameter within the method will affect the original variable outside the method as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Example&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In below we have defined the syntax of ref method. The ref method have retrun type for example int, float or string and a methodName that can be any suitable name of the method and we have defined the parameter ref with the first ref keword then it will have any datatype for example int, string and parameter name for example referenceParameter in below syntax then we have defined the body of parameter where we used this ref parameter and will assigne a value to this ref parameter.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;returnType methodName(parameters, ref dataType referenceParameter)
{
// Method body
// The method assigns a value to referenceParameter
// ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Basic structure of ref parameter
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Method Signature&lt;/strong&gt;:&lt;br&gt;
When defining a method that accepts a ref keyword, you specify the ref keyword before the parameter type in the method signature.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Argument Passing:&lt;/strong&gt;&lt;br&gt;
When calling the method, you must also use the ref keyword to indicate that you are passing a reference to a variable.&lt;/p&gt;
&lt;h2&gt;
  
  
  Example one with simple variable
&lt;/h2&gt;

&lt;p&gt;In the below example we have private class Program and this Program class have Main entry method. In Main entry method we have defined SimpleWithRef method which does not have any return type and has a ref parameter of integer type x. In the body of SimpleWithRef method we have assigned a value to x variable. In reality we are modifying the existing value with new value. Outside the SimpleWithRef method we have declared a integer type x vaiable and assinged a 10 value to this x variable. We are printing a value of x variable before call of SimpleWithRef method. Which is 10 before call. After this we are calling SimpleWithRef function that must have ref keyword then a variable name x. After this we are again printing the value of x. Now you can monitored that the original value of x parameter has changed after it's call. Which is now become 30.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using System;
public class Program
{
public static void Main(string[] args)
{
void Simple(int y)
{
y = 40; //Not Modifies the original 'y' variable
}


void SimpleWithRef(ref int x)
{
x = 30; // Modifies the original 'x' variable
}


int x = 10;
Console.WriteLine("Before call x value is=" + x);
SimpleWithRef(ref x); // Calling the SimpleWithRef function
Console.WriteLine("After call x value is=" + x);
int y = 20;
Console.WriteLine("Before cal y value is=" + y);
Simple(y); // Calling the Simple function
Console.WriteLine("After call y value is=" + y);
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Output&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Before call x value is=10&lt;br&gt;
After call x value is=30&lt;br&gt;
Before cal y value is=20&lt;br&gt;
After call y value is=20&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Example two with classes&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using System;
public class Program
{
public static void Main(string[] args)
{
Fruit objFruit = new Fruit(18, "WaterMelon", true);
int fieldPrice = objFruit.GetFruitPrice(); // Accessing a field fruit price
string fieldName = objFruit.GetFruitName(); // Accessing a field fruit name
bool fieldIsInMarket = objFruit.GetFruitIsInMarket(); // Accessing a field fruit is in market

Console.WriteLine("Fruit result before using ref keword");
Console.WriteLine("Fruit name: " + fieldName + " Fruit price:" + fieldPrice + " Is available in summer :" + fieldIsInMarket);

objFruit.SetFruit(ref objFruit.FruitPrice, ref objFruit.FruitName, ref objFruit.FruitIsAvialableInSummer);
Console.WriteLine("Fruit result after using ref keword without class");
Console.WriteLine("Fruit name: " + objFruit.FruitName + " Fruit price:" + objFruit.FruitPrice + " Is available in summer :" + objFruit.FruitIsAvialableInSummer);

objFruit.SetNewFruit(ref objFruit);
Console.WriteLine("Fruit result after using ref keword with class");
Console.WriteLine("Fruit name: " + objFruit.FruitName + " Fruit price:" + objFruit.FruitPrice + " Is available in summer :" + objFruit.FruitIsAvialableInSummer);

}
}

public class Fruit
{
// Fields (attributes or variables)
public int FruitPrice;
public string FruitName;
public bool FruitIsAvialableInSummer;

// Constructor
public Fruit(int price, string name, bool isAvailable)
{
FruitPrice = price;
FruitName = name;
FruitIsAvialableInSummer = isAvailable;
}

// Methods (functions or behaviors)
public int GetFruitPrice()
{
return FruitPrice;
}

public string GetFruitName()
{
return FruitName;
}

public bool GetFruitIsInMarket()
{
return FruitIsAvialableInSummer;
}

public void SetFruit(ref int FruitPrice, ref string FruitName, ref bool FruitIsAvialableInSummer)
{
FruitPrice = 28;
FruitName = "Orange";
FruitIsAvialableInSummer = false;
}

public void SetNewFruit(ref Fruit fruitChange)
{
fruitChange.FruitPrice = 23;
fruitChange.FruitName = "Mango";
fruitChange.FruitIsAvialableInSummer = true;
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Output&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Fruit result before using ref keword&lt;br&gt;
Fruit name: WaterMelon Fruit price:18 Is available in summer :True&lt;br&gt;
Fruit result after using ref keword without class&lt;br&gt;
Fruit name: Orange Fruit price:28 Is available in summer :False&lt;br&gt;
Fruit result after using ref keword with class&lt;br&gt;
Fruit name: Mamgo Fruit price:23 Is available in summer :True&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Example three with struct&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using System;
public class Program
{
public static void Main(string[] args)
{
Point p1 = new Point(10, 20);
Point p2 = p1; // Copying p1 to p2
p2.SetValuePoint(ref p2);
Console.WriteLine($"p1: {p1}"); // Output: p1: (10, 20)
Console.WriteLine($"p2: {p2}"); // Output: p2: (30, 20)
}
}

public struct Point
{
public int X;
public int Y;
public Point(int x, int y)
{
X = x;
Y = y;
}

public override string ToString()
{
return $"({X}, {Y})";
}

public void SetValuePoint(ref Point p2)
{
p2.X = 30; // Modifying p2
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Output&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;p1: (10, 20)&lt;br&gt;
p2: (30, 20)&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why we use ref keyword?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Modifying the Original Value:&lt;/strong&gt;&lt;br&gt;
When you need to modify the original variable out side the scope of declaration of method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Copying Large Structure Of Data&lt;/strong&gt;&lt;br&gt;
When you have need for passing a large structure of data from one location to another. You can pass this large data with ref kayword to get avoidance from copying of data after change in desired location.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Returing Multiple Values&lt;/strong&gt;&lt;br&gt;
When you have need of returning multiple value you can use ref keyword.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Summary&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;We can change the original value of a variable or class variable out the another class by ref keyword becasue ref keyword make a variable or class reference type.&lt;/p&gt;

&lt;p&gt;In C#, list themselves are reference types. This means that when you pass a list to a method or assign it to another variable, you're passing the reference to the list, not the list itself. Any changes made to the list within the method or through the assigned variable will affect the original list. so we don't need to send a list to outside the class with ref keword.&lt;/p&gt;

&lt;p&gt;In C#, structs are inherently value types, and you cannot directly change a struct to behave like a reference type but by using &lt;a href="https://c-sharptutorial.com/function/ref-function-in-csharp"&gt;ref parameter&lt;/a&gt; you can change the value of the variable of struct.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>coding</category>
      <category>programming</category>
      <category>softwaredevelopment</category>
    </item>
  </channel>
</rss>
