SlideShare a Scribd company logo
DOT NET PROGRAMMING CONCEPT
1. Define variable and constant.
A variable can be defined as a meaningful name that is given to a data storage location in
the computer memory that contains a value. Every variable associated with a data type
determines what type of value can be stored in the variable, for example an integer, such as
100, a decimal, such as 30.05, or a character, such as 'A'.
You can declare variables by using the following syntax:
<Data_type> <variable_name> ;
A constant is similar to a variable except that the value, which you assign to a constant,
cannot be changed, as in case of a variable. Constants must be initialized at the same time
they are declared. You can declare constants by using the following syntax:
const int interestRate = 10;
2. What is a data type? How many types of data types are there in .NET ?
A data type is a data storage format that can contain a specific type or range of values.
Whenever you declare variables, each variable must be assigned a specific data type. Some
common data types include integers, floating point, characters, and strings. The following
are the two types of data types available in .NET:
 Value type - Refers to the data type that contains the data. In other words, the
exact value or the data is directly stored in this data type. It means that when you
assign a value type variable to another variable, then it copies the value rather than
copying the reference of that variable. When you create a value type variable, a
single space in memory is allocated to store the value (stack memory). Primitive
data types, such as int, float, and char are examples of value type variables.
 Reference type - Refers to a data type that can access data by reference.
Reference is a value or an address that accesses a partic ular data by address, which
is stored elsewhere in memory (heap memory). You can say that reference is the
physical address of data, where the data is stored in memory or in the storage
device. Some built-in reference types variables in .Net are string, array, and object.
3. Mention the two major categories that distinctly classify the variables of C#
programs.
Variables that are defined in a C# program belong to two major categories: value
type and reference type. The variables that are based on value type contain a value that
is either allocated on a stack or allocated in-line in a structure. The variables that are based
on reference types store the memory address of a variable, which in turn stores the value
and are allocated on the heap. The variables that are based on value types have their own
copy of data and therefore operations done on one variable do not affect other variables.
The reference-type variables reflect the changes made in the referring variables.
Predict the output of the following code segment:
int x = 42;
int y = 12;
int w;
object o;
o = x;
w = y * (int)o;
Console.WriteLine(w);
/* The output of the code is 504. */
4. Which statement is used to replace multiple if-else statements in code.
In Visual Basic, the Select-Case statement is used to replace multiple If - Else statements
and in C#, theswitch-case statement is used to replace multiple if-else statements.
5. What is the syntax to declare a namespace in .NET?
In .NET, the namespace keyword is used to declare a namespace in the code.
The syntax for declaring a namespace in C# is:
namespace UserNameSpace;
The syntax for declaring a namespace in VB is:
Namespace UserNameSpace
6. What is the difference between constants and read-only variables that are used
in programs?
Constants perform the same tasks as read-only variables with some differences. The
differences between constants and read-only are
Constants:
1. Constants are dealt with at compile-time.
2. Constants supports value-type variables.
3. Constants should be used when it is very unlikely that the value will ever change.
Read-only:
1. Read-only variables are evaluated at runtime.
2. Read-only variables can hold reference type variables.
3. Read-only variables should be used when run-time calculation is required.
7. Differentiate between the while and for loop in C#.
The while and for loops are used to execute those units of code that need to be
repeatedly executed, unless the result of the specified condition evaluates to false. The only
difference between the two is in their syntax. The for loop is distinguished by setting an
explicit loop variable.
8. What is an identifier?
Identifiers are northing but names given to various entities uniquely identified in a program.
The name of identifiers must differ in spelling or casing. For
example, MyProg and myProg are two different identifiers. Programming languages, such
as C# and Visual Basic, strictly restrict the programmers from using any keyword as
identifiers. Programmers cannot develop a class whose name is public,
because, public is a keyword used to specify the accessibility of data in programs.
9. What does a break statement do in the switch statement?
The switch statement is a selection control statement that is used to handle multiple
choices and transfer control to the case statements within its body. The following code
snippet shows an example of the use of theswitch statement in C#:
switch(choice)
{
case 1:
console.WriteLine("First");
break;
case 2:
console.WriteLine("Second");
break;
default:
console.WriteLine("Wrong choice");
break;
}
In switch statements, the break statement is used at the end of a case statement.
The break statement is mandatory in C# and it avoids the fall through of
one case statement to another.
10. Explain keywords with example.
Keywords are those words that are reserved to be used for a specific task. These words
cannot be used as identifiers. You cannot use a keyword to define the name of a variable or
method. Keywords are used in programs to use the features of object -oriented
programming.
For example, the abstract keyword is used to implement abstraction and the inherits
keyword is used to implement inheritance by deriving subclasses in C# and Visual Basic,
respectively.
The new keyword is universally used in C# and Visual Basic to implement encapsulation by
creating objects.
11. Briefly explain the characteristics of value-type variables that are supported in
the C# programming language.
The variables that are based on value types directly contain values. The characteristics of
value-type variables that are supported in C# programming language are as follows:
 All value-type variables derive implicitly from the System.ValueType class
 You cannot derive any new type from a value type
 Value types have an implicit default constructor that initializes the default value of
that type
 The value type consists of two main categories:
 Structs - Summarizes small groups of related variables.
 Enumerations - Consists of a set of named constants.
12. Give the syntax of using the while loop in a C# program.
The syntax of using the while loop in C# is:
while(condition) //condition
{
//statements
}
You can find an example of using the while loop in C#:
int i = 0;
while(i < 5)
{
Console.WriteLine("{0} ", i);
i++;
}
The output of the preceding code is: 0 1 2 3 4 .
13. What is a parameter? Explain the new types of parameters introduced in C#
4.0.
A parameter is a special kind of variable, which is used in a function to provide a piece of
information or input to a caller function. These inputs are called arguments. In C#, the
different types of parameters are as follows:
 Value type - Refers that you do not need to provide any keyword with a parameter.
 Reference type - Refers that you need to mention the ref keyword with a
parameter.
 Output type - Refers that you need to mention the out keyword with a parameter.
 Optional parameter - Refers to the new parameter introduced in C# 4.0. It allows
you to neglect the parameters that have some predefined default values. The
example of optional parameter is as follows:
 public int Sum(int a, int b, int c = 0, int d = 0); /* c and d is
optional */
 Sum(10, 20); //10 + 20 + 0 + 0
 Sum(10, 20, 30); //10 + 20 + 30 + 0
 Sum(10, 20, 30, 40); //10 + 20 + 30 + 40
 Named parameter - Refers to the new parameter introduced in C# 4.0. Now you
can provide arguments by name rather than position. The example of the named
parameter is as follows:
 public void CreateAccount(string name, string address = "unknown", int
age = 0);
 CreateAccount("Sara", age: 30);
 CreateAccount(address: "India", name: "Sara");
14. Briefly explain the characteristics of reference-type variables that are
supported in the C# programming language.
The variables that are based on reference types store references to the actual data. The
keywords that are used to declare reference types are:
1. Class - Refers to the primary building block for the programs, which is used to
encapsulate variables and methods into a single unit.
2. Interface - Contains only the signatures of methods, properties, events, or
indexers.
3. Delegate - Refers to a reference type that is used to encapsulate a named or
anonymous method.
15. What are the different types of literals?
A literal is a textual representation of a particular value of a type.
The different types of literals in Visual Basic are:
 Boolean Literals - Refers to the True and False literals that map to the true and false
state, respectively.
 Integer Literals - Refers to literals that can be decimal (base 10), hexadecimal (base
16), or octal (base 8).
 Floating-Point Literals - Refers to an integer literal followed by an optional decimal
point By default, a floating-point literal is of type Double.
 String Literals - Refers to a sequence of zero or more Unicode characters beginning
and ending with an ASCII double-quote character.
 Character Literals - Represents a single Unicode character of the Char type.
 Date Literals - Represents time expressed as a value of the Date type.
 Nothing - Refers to a literal that does not have a type and is convertible to all types
in the type system.
The different types of literals in C# are:
 Boolean literals - Refers to the True and False literals that map to the true and false
states, respectively.
 Integer literals - Refers to literals that are used to write values of types int, uint,
long, and ulong.
 Real literals - Refers to literals that are used to write values of types float, double,
and decimal.
 Character literals - Represents a single character that usually consists of a character
in quotes, such as 'a'.
 String literals - Refers to string literals, which can be of two types in C#:
 A regular string literal consists of zero or more characters enclosed in double
quotes, such as "hello".
 A verbatim string literal consists of the @ character followed by a double-
quote character, such as @"hello".
 The Null literal - Represents the null-type.
16. What is the main difference between sub-procedure and function?
The sub-procedure is a block of multiple visual basic statements within Sub and End Sub
statements. It is used to perform certain tasks, suc h as changing properties of objects,
receiving or processing data, and displaying an output. You can define a sub-procedure
anywhere in a program, such as in modules, structures, and classes.
We can also provide arguments in a sub-procedure; however, it does not return a new
value.
The function is also a set of statements within the Function and End Function statements. It
is similar to sub-procedure and performs the same task. The main difference between a
function and a sub-procedure is that sub-procedures do not return a value while functions
do.
17. Determine the output of the code snippet.
int a = 29;
a--;
a -= ++a;
Console.WriteLine("The value of a is: {0}", a);
/* The output of the code is -1. */
18. Differentiate between Boxing and Unboxing.
When a value type is converted to an object type, the process is known as boxing; whereas,
when an object type is converted to a value type, the process is known as unboxing.
Boxing and unboxing enable value types to be treated as objects. Boxing a value type
packages it inside an instance of the Object reference type. This allows the value type to be
stored on the garbage collected heap. Unboxing extracts the value type from the object. In
this example, the integer variable i is boxed and assigned to object obj.
Example:
int i = 123;
object obj = i; /* Thi line boxes i. */
/* The object obj can then be unboxed and assigned to integer variable i: */
i = (int)obj; // unboxing
19. Give the syntax of using the for loop in C# code?
The syntax of using the for loop in C# code is given as follows:
for(initializer; condition; loop expression)
{
//statements
}
In the preceding syntax, initializer is the initial value of the variable, condition is the
expression that is checked before the execution of the for loop, and loop expression either
increments or decrements the loop counter.
The example of using the for loop in C# is shown in the following code snippet:
for(int i = 0; i < 5; i++)
Console.WriteLine("Hello");
In the preceding code snippet, the word Hello will be displayed for five times in the output
window.
Ad

More Related Content

What's hot (20)

C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#
Dr.Neeraj Kumar Pandey
 
Chapter1 c programming data types, variables and constants
Chapter1 c programming   data types, variables and constantsChapter1 c programming   data types, variables and constants
Chapter1 c programming data types, variables and constants
vinay arora
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
C# Value Data Types and Reference Data Types
C# Value Data Types and Reference Data TypesC# Value Data Types and Reference Data Types
C# Value Data Types and Reference Data Types
Micheal Ogundero
 
Python Interview questions 2020
Python Interview questions 2020Python Interview questions 2020
Python Interview questions 2020
VigneshVijay21
 
Chapter 2 c#
Chapter 2 c#Chapter 2 c#
Chapter 2 c#
megersaoljira
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data types
Manisha Keim
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
Kamal Acharya
 
Top C Language Interview Questions and Answer
Top C Language Interview Questions and AnswerTop C Language Interview Questions and Answer
Top C Language Interview Questions and Answer
Vineet Kumar Saini
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
C presentation book
C presentation bookC presentation book
C presentation book
krunal1210
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
Mahender Boda
 
Methods in C#
Methods in C#Methods in C#
Methods in C#
Prasanna Kumar SM
 
3 data-types-in-c
3 data-types-in-c3 data-types-in-c
3 data-types-in-c
teach4uin
 
Basic
BasicBasic
Basic
Shehrevar Davierwala
 
Fundamentals of Programming Chapter 4
Fundamentals of Programming Chapter 4Fundamentals of Programming Chapter 4
Fundamentals of Programming Chapter 4
Mohd Harris Ahmad Jaal
 
Basic Data Types in C++
Basic Data Types in C++ Basic Data Types in C++
Basic Data Types in C++
Hridoy Bepari
 
Lect 9(pointers) Zaheer Abbas
Lect 9(pointers) Zaheer AbbasLect 9(pointers) Zaheer Abbas
Lect 9(pointers) Zaheer Abbas
Information Technology Center
 
Data type
Data typeData type
Data type
Isha Aggarwal
 
C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#
Dr.Neeraj Kumar Pandey
 
Chapter1 c programming data types, variables and constants
Chapter1 c programming   data types, variables and constantsChapter1 c programming   data types, variables and constants
Chapter1 c programming data types, variables and constants
vinay arora
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
C# Value Data Types and Reference Data Types
C# Value Data Types and Reference Data TypesC# Value Data Types and Reference Data Types
C# Value Data Types and Reference Data Types
Micheal Ogundero
 
Python Interview questions 2020
Python Interview questions 2020Python Interview questions 2020
Python Interview questions 2020
VigneshVijay21
 
Concept of c data types
Concept of c data typesConcept of c data types
Concept of c data types
Manisha Keim
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
Kamal Acharya
 
Top C Language Interview Questions and Answer
Top C Language Interview Questions and AnswerTop C Language Interview Questions and Answer
Top C Language Interview Questions and Answer
Vineet Kumar Saini
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
C presentation book
C presentation bookC presentation book
C presentation book
krunal1210
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
3 data-types-in-c
3 data-types-in-c3 data-types-in-c
3 data-types-in-c
teach4uin
 
Basic Data Types in C++
Basic Data Types in C++ Basic Data Types in C++
Basic Data Types in C++
Hridoy Bepari
 

Viewers also liked (6)

занимательная география
занимательная географиязанимательная география
занимательная география
petrovich25l
 
Eid collection 2015 @ moksha fashions
Eid collection 2015 @ moksha fashionsEid collection 2015 @ moksha fashions
Eid collection 2015 @ moksha fashions
MOKSHA FASHIONS
 
занимательная география
занимательная географиязанимательная география
занимательная география
petrovich25l
 
занимательная география
занимательная географиязанимательная география
занимательная география
petrovich25l
 
Ivona lazarević železnički saobraćaj
Ivona lazarević   železnički saobraćajIvona lazarević   železnički saobraćaj
Ivona lazarević železnički saobraćaj
Тошић Роберт
 
Palate presentation
Palate presentationPalate presentation
Palate presentation
Gaurav Chaturvedi
 
занимательная география
занимательная географиязанимательная география
занимательная география
petrovich25l
 
Eid collection 2015 @ moksha fashions
Eid collection 2015 @ moksha fashionsEid collection 2015 @ moksha fashions
Eid collection 2015 @ moksha fashions
MOKSHA FASHIONS
 
занимательная география
занимательная географиязанимательная география
занимательная география
petrovich25l
 
занимательная география
занимательная географиязанимательная география
занимательная география
petrovich25l
 
Ivona lazarević železnički saobraćaj
Ivona lazarević   železnički saobraćajIvona lazarević   železnički saobraćaj
Ivona lazarević železnički saobraćaj
Тошић Роберт
 
Ad

Similar to Dot net programming concept (20)

Basic Structure Of C++
Basic Structure Of C++Basic Structure Of C++
Basic Structure Of C++
DevangiParekh1
 
C# chap 4
C# chap 4C# chap 4
C# chap 4
Shehrevar Davierwala
 
programming for problem solving in C and C++.pptx
programming for problem solving in C and C++.pptxprogramming for problem solving in C and C++.pptx
programming for problem solving in C and C++.pptx
BamaSivasubramanianP
 
Notes(1).pptx
Notes(1).pptxNotes(1).pptx
Notes(1).pptx
InfinityWorld3
 
Interview Questions For C Language
Interview Questions For C Language Interview Questions For C Language
Interview Questions For C Language
Rowank2
 
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
Rowank2
 
Interview Questions For C Language .pptx
Interview Questions For C Language .pptxInterview Questions For C Language .pptx
Interview Questions For C Language .pptx
Rowank2
 
C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01
Zafor Iqbal
 
C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer CentreC programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centre
jatin batra
 
C presentation! BATRA COMPUTER CENTRE
C presentation! BATRA  COMPUTER  CENTRE C presentation! BATRA  COMPUTER  CENTRE
C presentation! BATRA COMPUTER CENTRE
jatin batra
 
Structured Languages
Structured LanguagesStructured Languages
Structured Languages
Mufaddal Nullwala
 
Introduction to Programming Fundamentals 3.pdf
Introduction to Programming Fundamentals 3.pdfIntroduction to Programming Fundamentals 3.pdf
Introduction to Programming Fundamentals 3.pdf
AbrehamKassa
 
A tour of C# - Overview _ Microsoft Learn.pdf
A tour of C# - Overview _ Microsoft Learn.pdfA tour of C# - Overview _ Microsoft Learn.pdf
A tour of C# - Overview _ Microsoft Learn.pdf
ParasJain570452
 
C programming notes
C programming notesC programming notes
C programming notes
Prof. Dr. K. Adisesha
 
Embedded C The IoT Academy
Embedded C The IoT AcademyEmbedded C The IoT Academy
Embedded C The IoT Academy
The IOT Academy
 
C programming notes.pdf
C programming notes.pdfC programming notes.pdf
C programming notes.pdf
AdiseshaK
 
unit 1 (1).pptx
unit 1 (1).pptxunit 1 (1).pptx
unit 1 (1).pptx
PriyadarshiniS28
 
unit 1 cpds.pptx
unit 1 cpds.pptxunit 1 cpds.pptx
unit 1 cpds.pptx
madhurij54
 
Pc module1
Pc module1Pc module1
Pc module1
SANTOSH RATH
 
introduction to programming using ANSI C
introduction to programming using ANSI Cintroduction to programming using ANSI C
introduction to programming using ANSI C
JNTUK KAKINADA
 
Basic Structure Of C++
Basic Structure Of C++Basic Structure Of C++
Basic Structure Of C++
DevangiParekh1
 
programming for problem solving in C and C++.pptx
programming for problem solving in C and C++.pptxprogramming for problem solving in C and C++.pptx
programming for problem solving in C and C++.pptx
BamaSivasubramanianP
 
Interview Questions For C Language
Interview Questions For C Language Interview Questions For C Language
Interview Questions For C Language
Rowank2
 
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
C Language Interview Questions: Data Types, Pointers, Data Structures, Memory...
Rowank2
 
Interview Questions For C Language .pptx
Interview Questions For C Language .pptxInterview Questions For C Language .pptx
Interview Questions For C Language .pptx
Rowank2
 
C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01
Zafor Iqbal
 
C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer CentreC programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centre
jatin batra
 
C presentation! BATRA COMPUTER CENTRE
C presentation! BATRA  COMPUTER  CENTRE C presentation! BATRA  COMPUTER  CENTRE
C presentation! BATRA COMPUTER CENTRE
jatin batra
 
Introduction to Programming Fundamentals 3.pdf
Introduction to Programming Fundamentals 3.pdfIntroduction to Programming Fundamentals 3.pdf
Introduction to Programming Fundamentals 3.pdf
AbrehamKassa
 
A tour of C# - Overview _ Microsoft Learn.pdf
A tour of C# - Overview _ Microsoft Learn.pdfA tour of C# - Overview _ Microsoft Learn.pdf
A tour of C# - Overview _ Microsoft Learn.pdf
ParasJain570452
 
Embedded C The IoT Academy
Embedded C The IoT AcademyEmbedded C The IoT Academy
Embedded C The IoT Academy
The IOT Academy
 
C programming notes.pdf
C programming notes.pdfC programming notes.pdf
C programming notes.pdf
AdiseshaK
 
unit 1 cpds.pptx
unit 1 cpds.pptxunit 1 cpds.pptx
unit 1 cpds.pptx
madhurij54
 
introduction to programming using ANSI C
introduction to programming using ANSI Cintroduction to programming using ANSI C
introduction to programming using ANSI C
JNTUK KAKINADA
 
Ad

Recently uploaded (20)

IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Harmonizing Multi-Agent Intelligence | Open Data Science Conference | Gary Ar...
Harmonizing Multi-Agent Intelligence | Open Data Science Conference | Gary Ar...Harmonizing Multi-Agent Intelligence | Open Data Science Conference | Gary Ar...
Harmonizing Multi-Agent Intelligence | Open Data Science Conference | Gary Ar...
Gary Arora
 
Understanding SEO in the Age of AI.pdf
Understanding SEO in the Age of AI.pdfUnderstanding SEO in the Age of AI.pdf
Understanding SEO in the Age of AI.pdf
Fulcrum Concepts, LLC
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
Slack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teamsSlack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teams
Nacho Cougil
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Vasileios Komianos
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025
Damco Salesforce Services
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
Cybersecurity Tools and Technologies - Microsoft Certificate
Cybersecurity Tools and Technologies - Microsoft CertificateCybersecurity Tools and Technologies - Microsoft Certificate
Cybersecurity Tools and Technologies - Microsoft Certificate
VICTOR MAESTRE RAMIREZ
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Top Hyper-Casual Game Studio Services
Top  Hyper-Casual  Game  Studio ServicesTop  Hyper-Casual  Game  Studio Services
Top Hyper-Casual Game Studio Services
Nova Carter
 
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Alan Dix
 
MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...
MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...
MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...
ICT Frame Magazine Pvt. Ltd.
 
Google DeepMind’s New AI Coding Agent AlphaEvolve.pdf
Google DeepMind’s New AI Coding Agent AlphaEvolve.pdfGoogle DeepMind’s New AI Coding Agent AlphaEvolve.pdf
Google DeepMind’s New AI Coding Agent AlphaEvolve.pdf
derrickjswork
 
ICDCC 2025: Securing Agentic AI - Eryk Budi Pratama.pdf
ICDCC 2025: Securing Agentic AI - Eryk Budi Pratama.pdfICDCC 2025: Securing Agentic AI - Eryk Budi Pratama.pdf
ICDCC 2025: Securing Agentic AI - Eryk Budi Pratama.pdf
Eryk Budi Pratama
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
IT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information TechnologyIT488 Wireless Sensor Networks_Information Technology
IT488 Wireless Sensor Networks_Information Technology
SHEHABALYAMANI
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Harmonizing Multi-Agent Intelligence | Open Data Science Conference | Gary Ar...
Harmonizing Multi-Agent Intelligence | Open Data Science Conference | Gary Ar...Harmonizing Multi-Agent Intelligence | Open Data Science Conference | Gary Ar...
Harmonizing Multi-Agent Intelligence | Open Data Science Conference | Gary Ar...
Gary Arora
 
Understanding SEO in the Age of AI.pdf
Understanding SEO in the Age of AI.pdfUnderstanding SEO in the Age of AI.pdf
Understanding SEO in the Age of AI.pdf
Fulcrum Concepts, LLC
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
Slack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teamsSlack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teams
Nacho Cougil
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Vasileios Komianos
 
machines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdfmachines-for-woodworking-shops-en-compressed.pdf
machines-for-woodworking-shops-en-compressed.pdf
AmirStern2
 
Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025
Damco Salesforce Services
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
Cybersecurity Tools and Technologies - Microsoft Certificate
Cybersecurity Tools and Technologies - Microsoft CertificateCybersecurity Tools and Technologies - Microsoft Certificate
Cybersecurity Tools and Technologies - Microsoft Certificate
VICTOR MAESTRE RAMIREZ
 
IT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information TechnologyIT484 Cyber Forensics_Information Technology
IT484 Cyber Forensics_Information Technology
SHEHABALYAMANI
 
Cybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and MitigationCybersecurity Threat Vectors and Mitigation
Cybersecurity Threat Vectors and Mitigation
VICTOR MAESTRE RAMIREZ
 
Top Hyper-Casual Game Studio Services
Top  Hyper-Casual  Game  Studio ServicesTop  Hyper-Casual  Game  Studio Services
Top Hyper-Casual Game Studio Services
Nova Carter
 
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Alan Dix
 
MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...
MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...
MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...
ICT Frame Magazine Pvt. Ltd.
 
Google DeepMind’s New AI Coding Agent AlphaEvolve.pdf
Google DeepMind’s New AI Coding Agent AlphaEvolve.pdfGoogle DeepMind’s New AI Coding Agent AlphaEvolve.pdf
Google DeepMind’s New AI Coding Agent AlphaEvolve.pdf
derrickjswork
 
ICDCC 2025: Securing Agentic AI - Eryk Budi Pratama.pdf
ICDCC 2025: Securing Agentic AI - Eryk Budi Pratama.pdfICDCC 2025: Securing Agentic AI - Eryk Budi Pratama.pdf
ICDCC 2025: Securing Agentic AI - Eryk Budi Pratama.pdf
Eryk Budi Pratama
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 

Dot net programming concept

  • 1. DOT NET PROGRAMMING CONCEPT 1. Define variable and constant. A variable can be defined as a meaningful name that is given to a data storage location in the computer memory that contains a value. Every variable associated with a data type determines what type of value can be stored in the variable, for example an integer, such as 100, a decimal, such as 30.05, or a character, such as 'A'. You can declare variables by using the following syntax: <Data_type> <variable_name> ; A constant is similar to a variable except that the value, which you assign to a constant, cannot be changed, as in case of a variable. Constants must be initialized at the same time they are declared. You can declare constants by using the following syntax: const int interestRate = 10; 2. What is a data type? How many types of data types are there in .NET ? A data type is a data storage format that can contain a specific type or range of values. Whenever you declare variables, each variable must be assigned a specific data type. Some common data types include integers, floating point, characters, and strings. The following are the two types of data types available in .NET:  Value type - Refers to the data type that contains the data. In other words, the exact value or the data is directly stored in this data type. It means that when you assign a value type variable to another variable, then it copies the value rather than copying the reference of that variable. When you create a value type variable, a single space in memory is allocated to store the value (stack memory). Primitive data types, such as int, float, and char are examples of value type variables.  Reference type - Refers to a data type that can access data by reference. Reference is a value or an address that accesses a partic ular data by address, which is stored elsewhere in memory (heap memory). You can say that reference is the physical address of data, where the data is stored in memory or in the storage device. Some built-in reference types variables in .Net are string, array, and object. 3. Mention the two major categories that distinctly classify the variables of C# programs. Variables that are defined in a C# program belong to two major categories: value type and reference type. The variables that are based on value type contain a value that is either allocated on a stack or allocated in-line in a structure. The variables that are based on reference types store the memory address of a variable, which in turn stores the value
  • 2. and are allocated on the heap. The variables that are based on value types have their own copy of data and therefore operations done on one variable do not affect other variables. The reference-type variables reflect the changes made in the referring variables. Predict the output of the following code segment: int x = 42; int y = 12; int w; object o; o = x; w = y * (int)o; Console.WriteLine(w); /* The output of the code is 504. */ 4. Which statement is used to replace multiple if-else statements in code. In Visual Basic, the Select-Case statement is used to replace multiple If - Else statements and in C#, theswitch-case statement is used to replace multiple if-else statements. 5. What is the syntax to declare a namespace in .NET? In .NET, the namespace keyword is used to declare a namespace in the code. The syntax for declaring a namespace in C# is: namespace UserNameSpace; The syntax for declaring a namespace in VB is: Namespace UserNameSpace 6. What is the difference between constants and read-only variables that are used in programs? Constants perform the same tasks as read-only variables with some differences. The differences between constants and read-only are Constants: 1. Constants are dealt with at compile-time. 2. Constants supports value-type variables. 3. Constants should be used when it is very unlikely that the value will ever change.
  • 3. Read-only: 1. Read-only variables are evaluated at runtime. 2. Read-only variables can hold reference type variables. 3. Read-only variables should be used when run-time calculation is required. 7. Differentiate between the while and for loop in C#. The while and for loops are used to execute those units of code that need to be repeatedly executed, unless the result of the specified condition evaluates to false. The only difference between the two is in their syntax. The for loop is distinguished by setting an explicit loop variable. 8. What is an identifier? Identifiers are northing but names given to various entities uniquely identified in a program. The name of identifiers must differ in spelling or casing. For example, MyProg and myProg are two different identifiers. Programming languages, such as C# and Visual Basic, strictly restrict the programmers from using any keyword as identifiers. Programmers cannot develop a class whose name is public, because, public is a keyword used to specify the accessibility of data in programs. 9. What does a break statement do in the switch statement? The switch statement is a selection control statement that is used to handle multiple choices and transfer control to the case statements within its body. The following code snippet shows an example of the use of theswitch statement in C#: switch(choice) { case 1: console.WriteLine("First"); break; case 2: console.WriteLine("Second"); break; default: console.WriteLine("Wrong choice"); break; } In switch statements, the break statement is used at the end of a case statement.
  • 4. The break statement is mandatory in C# and it avoids the fall through of one case statement to another. 10. Explain keywords with example. Keywords are those words that are reserved to be used for a specific task. These words cannot be used as identifiers. You cannot use a keyword to define the name of a variable or method. Keywords are used in programs to use the features of object -oriented programming. For example, the abstract keyword is used to implement abstraction and the inherits keyword is used to implement inheritance by deriving subclasses in C# and Visual Basic, respectively. The new keyword is universally used in C# and Visual Basic to implement encapsulation by creating objects. 11. Briefly explain the characteristics of value-type variables that are supported in the C# programming language. The variables that are based on value types directly contain values. The characteristics of value-type variables that are supported in C# programming language are as follows:  All value-type variables derive implicitly from the System.ValueType class  You cannot derive any new type from a value type  Value types have an implicit default constructor that initializes the default value of that type  The value type consists of two main categories:  Structs - Summarizes small groups of related variables.  Enumerations - Consists of a set of named constants. 12. Give the syntax of using the while loop in a C# program. The syntax of using the while loop in C# is: while(condition) //condition { //statements } You can find an example of using the while loop in C#: int i = 0;
  • 5. while(i < 5) { Console.WriteLine("{0} ", i); i++; } The output of the preceding code is: 0 1 2 3 4 . 13. What is a parameter? Explain the new types of parameters introduced in C# 4.0. A parameter is a special kind of variable, which is used in a function to provide a piece of information or input to a caller function. These inputs are called arguments. In C#, the different types of parameters are as follows:  Value type - Refers that you do not need to provide any keyword with a parameter.  Reference type - Refers that you need to mention the ref keyword with a parameter.  Output type - Refers that you need to mention the out keyword with a parameter.  Optional parameter - Refers to the new parameter introduced in C# 4.0. It allows you to neglect the parameters that have some predefined default values. The example of optional parameter is as follows:  public int Sum(int a, int b, int c = 0, int d = 0); /* c and d is optional */  Sum(10, 20); //10 + 20 + 0 + 0  Sum(10, 20, 30); //10 + 20 + 30 + 0  Sum(10, 20, 30, 40); //10 + 20 + 30 + 40  Named parameter - Refers to the new parameter introduced in C# 4.0. Now you can provide arguments by name rather than position. The example of the named parameter is as follows:  public void CreateAccount(string name, string address = "unknown", int age = 0);  CreateAccount("Sara", age: 30);  CreateAccount(address: "India", name: "Sara"); 14. Briefly explain the characteristics of reference-type variables that are supported in the C# programming language. The variables that are based on reference types store references to the actual data. The keywords that are used to declare reference types are:
  • 6. 1. Class - Refers to the primary building block for the programs, which is used to encapsulate variables and methods into a single unit. 2. Interface - Contains only the signatures of methods, properties, events, or indexers. 3. Delegate - Refers to a reference type that is used to encapsulate a named or anonymous method. 15. What are the different types of literals? A literal is a textual representation of a particular value of a type. The different types of literals in Visual Basic are:  Boolean Literals - Refers to the True and False literals that map to the true and false state, respectively.  Integer Literals - Refers to literals that can be decimal (base 10), hexadecimal (base 16), or octal (base 8).  Floating-Point Literals - Refers to an integer literal followed by an optional decimal point By default, a floating-point literal is of type Double.  String Literals - Refers to a sequence of zero or more Unicode characters beginning and ending with an ASCII double-quote character.  Character Literals - Represents a single Unicode character of the Char type.  Date Literals - Represents time expressed as a value of the Date type.  Nothing - Refers to a literal that does not have a type and is convertible to all types in the type system. The different types of literals in C# are:  Boolean literals - Refers to the True and False literals that map to the true and false states, respectively.  Integer literals - Refers to literals that are used to write values of types int, uint, long, and ulong.  Real literals - Refers to literals that are used to write values of types float, double, and decimal.  Character literals - Represents a single character that usually consists of a character in quotes, such as 'a'.  String literals - Refers to string literals, which can be of two types in C#:  A regular string literal consists of zero or more characters enclosed in double quotes, such as "hello".  A verbatim string literal consists of the @ character followed by a double- quote character, such as @"hello".
  • 7.  The Null literal - Represents the null-type. 16. What is the main difference between sub-procedure and function? The sub-procedure is a block of multiple visual basic statements within Sub and End Sub statements. It is used to perform certain tasks, suc h as changing properties of objects, receiving or processing data, and displaying an output. You can define a sub-procedure anywhere in a program, such as in modules, structures, and classes. We can also provide arguments in a sub-procedure; however, it does not return a new value. The function is also a set of statements within the Function and End Function statements. It is similar to sub-procedure and performs the same task. The main difference between a function and a sub-procedure is that sub-procedures do not return a value while functions do. 17. Determine the output of the code snippet. int a = 29; a--; a -= ++a; Console.WriteLine("The value of a is: {0}", a); /* The output of the code is -1. */ 18. Differentiate between Boxing and Unboxing. When a value type is converted to an object type, the process is known as boxing; whereas, when an object type is converted to a value type, the process is known as unboxing. Boxing and unboxing enable value types to be treated as objects. Boxing a value type packages it inside an instance of the Object reference type. This allows the value type to be stored on the garbage collected heap. Unboxing extracts the value type from the object. In this example, the integer variable i is boxed and assigned to object obj. Example: int i = 123; object obj = i; /* Thi line boxes i. */ /* The object obj can then be unboxed and assigned to integer variable i: */ i = (int)obj; // unboxing
  • 8. 19. Give the syntax of using the for loop in C# code? The syntax of using the for loop in C# code is given as follows: for(initializer; condition; loop expression) { //statements } In the preceding syntax, initializer is the initial value of the variable, condition is the expression that is checked before the execution of the for loop, and loop expression either increments or decrements the loop counter. The example of using the for loop in C# is shown in the following code snippet: for(int i = 0; i < 5; i++) Console.WriteLine("Hello"); In the preceding code snippet, the word Hello will be displayed for five times in the output window.
  翻译: