Define what are value types and reference types?

1 Answer

Answer :

Value types are stored in the Stack.
Examples: bool, byte, chat, decimal, double, enum, float, int, long, byte, short, strut, uint, ulong, short.

Reference types are stored in the Heap.
Examples: class, delegate, interface, object, string.

Related questions

Description : Define what are reference types in C#?

Last Answer : Below is the list of reference types in C# – 1. class 2. string 3. interface 4. object

Description : Define what is the difference between value type and reference type?

Last Answer : 1. Value types are stored on the stack and when a value of a variable is assigned to another variable. 2. Reference types are stored on the heap, and when an assignment between two reference variables occurs.

Description : Briefly explain what is meant by a reference type and a value type.

Last Answer : A value type holds all of the data represented by the variable within the variable itself. A reference type contains a reference to a memory address that holds the data instead of the actual data itself. 

Description : How do you convert a value-type to a reference-type?

Last Answer : Use Boxing.

Description : What is a value type and a reference type? 

Last Answer : A reference type is known by a reference to a memory location on the heap. A value type is directly stored in a memory location on the stack. A reference type is essentially a pointer, dereferencing the pointer takes more time than directly accessing the direct memory location of a value type.

Description : How do you convert a value-type to a reference-type? 

Last Answer : Use Boxing.

Description : Is String is Value Type or Reference Type in C#?

Last Answer : A string is an object(Reference Type).

Description : Define what are value types in C#?

Last Answer : Below is the list of value types in C# – decimal int byte enum double long float

Description : Can operator parameters be reference parameters?

Last Answer : No

Description : What is a reference parameter? 

Last Answer : Reference parameters reference the original object whereas value parameters make a local copy and do not affect the original. Some example code is shown: using System; namespace Console1 { class Class1 { ... public string TestValue; } The output for this is: 2 1 New value New value

Description : Define what are the different types of polymorphism?

Last Answer : There are two types of polymorphism. They are: Compile time Polymorphism Run time Polymorphism

Description : Define what are the different types of literals in C#?

Last Answer : Boolean literals: True and False are literals of the Boolean type that map to the true and false state, respectively. Integer literals: Used to write values of types Int, uint, long, and ulong. Real ... by a double-quote character, such as © hello . The Null literal: Represents the null-type.

Description : Define what are the different types of variables in C#?

Last Answer : Different types of variables used in C# are : static variables instance variable value parameters reference parameters array elements output parameters local variables

Description : Define what are the types of errors?

Last Answer : Syntax error Logic error Runtime error

Description : Define what is literals and their types?

Last Answer : Literals are value constants assigned to variables in a program. C# supports several types of literals are Integer Literals Real literals Boolean Literals Single character literals String Literals Backslash character literals

Description : Define what are the different types of Caching?

Last Answer : There are three types of Caching: 1. Output Caching: stores the responses from an asp.net page. 2. Fragment Caching: Only caches/stores the portion of the page (User Control) 3. Data Caching: is Programmatic way to Cache objects for performance.

Description : Define what are the two data types available in C#?

Last Answer : Value type Reference type

Description : Define what are the different types of statements supported in C#?

Last Answer : C# supports several different kinds of statements are Block statements Declaration statements Expression statements Selection statements Iteration statements Jump statements Try catch statements Checked and unchecked Lock statement

Description : Are value types are slower to pass as method parameters? 

Last Answer : Yes

Description : Describe 5 numeric value types ranges. 

Last Answer : sbyte -128 to 127, byte 0 – 255, short -32,768 to 32,767, int -2,147,483,648 to 2,147,483,647, ulong 0 to 18,446,744,073,709,551,615 

Description : What is purpose of Assembly Linker or define SDK Tool in .NET Framework?

Last Answer : Answer: In .NET whole the working should be with the helps of DLLs.So all of Visual Studio .Net compilers gernate assemblies or u can say dll.If we want to create an assembly with ... Studio .Net .This multi file can contain modules that are written in diffrenet langauage in one application.

Description : What does the Initial Catalog parameter define in the connection string?

Last Answer : The database name to connect to. 

Description : Write code to define and use your own custom attribute.

Last Answer : (From MSDN) // cs_attributes_retr.cs using System; [AttributeUsage(AttributeTargets.Class|AttributeTargets.Struct, AllowMultiple=true)] public class Author : Attribute { public Author(string name) { this.name ... double version; string name; public string GetName() { return name; } }

Description : What does the Initial Catalog parameter define in the connection string?

Last Answer : The database name to connect to.

Description : Define what are the difference between const and readonly?

Last Answer : A const cannot be static, while readonly can be static. A const need to be declared and initialized at declaration only, while a readonly can be initialized at the declaration or by the code in the ... A const's value is evaluated at design time, while a read-only value is evaluated at runtime.

Description : Define what are the advantages of getting and set properties in C#?

Last Answer : 1. The get property accessor is used to return the property value. 2. The set property accessor is used to assign a new value.

Description : Define what is a New modifier?

Last Answer : The new modifier hides a member of the base class. C# supports only hide by signature.

Description : Define what is the Static Method?

Last Answer : It is possible to declare a method as Static provided that they don’t attempt to access any instance data or other instance methods.

Description : Define what is the difference between an abstract method & virtual method?

Last Answer : An Abstract method does not provide an implementation and forces overriding to the deriving class (unless the deriving class also an abstract class), whereas the virtual method has an ... abstract method does not provide implementation & forces the derived class to override the method.

Description : Define what is the difference between a class and an Interface?

Last Answer : 1. Abstract classes can have implementations for some of its members, but the interface can't have implementation for any of its members. 2. Interfaces cannot have fields whereas an ... 5. Abstract class members can have access modifiers whereas interface members cannot have access modifiers.

Description : Define what are sealed classes in c#?

Last Answer : The sealed modifier is used to prevent derivation from a class. A compile-time error occurs if a sealed class is specified as the base class of another class.

Description : Define what is the main difference between a sub procedure and a function?

Last Answer : Sub procedures do not return a value, while functions do.

Description : Define what is a basic difference between the while loop and do-while loop in C#?

Last Answer : The while loop tests its condition at the beginning, which means that the enclosed set of statements run for zero or more number of times if the condition evaluates to true. The do while loop iterates a set of statements at least once and then checks the condition at the end.

Description : Define what is the syntax to inherit from a class in C#?

Last Answer : When a class is derived from another class, then the members of the base class become the members of the derived class. The access modifier used while accessing members of the base class specifies ... syntax to inherit a class from another class In C# is as follows: class MyNewClass : MyBaseClass

Description : Define what is a static member?

Last Answer : The member defined as static which can be invoked directly from the class level, rather than from its instance.

Description : Define what Command is used to implement properties in C#?

Last Answer : get & set access modifiers are used to implement properties in c#.

Description : Define what is the difference between compile-time polymorphism and run-time polymorphism?

Last Answer : Compile time Polymorphism Compile time Polymorphism also known as method overloading. Method overloading means having two or more methods with the same name but with different signatures. Run time ... or more methods with the same name, same signature but with a different implementation.

Description : Define what is Generic?

Last Answer : 1. Generic help us to create flexible strong type collection. 2. Generic basically separate the logic from the datatype in order to maintain better reusability, better maintainability, etc.

Description : Define what are constructors and destructors?

Last Answer : Constructors and destructors are special methods. Constructors and destructors are special methods for every class. Each class has its own constructor and destructor and are called automatically when the ... access the class and the destructor destroys them when the objects are not required anymore.

Description : Define what is the difference between Shadowing and Overriding?

Last Answer : Overriding redefines only the implementation while shadowing redefines the whole element. In overriding derived classes can refer the parent class element by using “ME” keyword, but in shadowing you can access it by “MY BASE”.

Description : Define what is the main use of delegates in C#?

Last Answer : Delegates are mainly used to define call back methods.

Description : Define what is nested class?

Last Answer : Nested classes are classes within classes. A nested class is any class whose declaration occurs within the body of another class or interface.

Description : Define what is the main difference between a sub procedure and a function?

Last Answer : Sub procedures do not return a value, while functions do.

Description : Define what is meant by data encapsulation?

Last Answer : Data encapsulation also referred to as data hiding, is the mechanism whereby the implementation details of a class are kept hidden from the user. The user can only perform a restricted set of operations on the hidden members of the class by executing special functions called methods.

Description : Define what is an identifier?

Last Answer : Identifiers are nothing but names given to various entities uniquely identified in a program.

Description : Define what is an event?

Last Answer : An event is an action performed based on another method of the program. An event is a delegate type dass member that is used by an object or a class to provide a notification to other objects that an event has occurred. An event can be declared with the help of the event keyword.

Description : Define what are the different ways a method can be overloaded?

Last Answer : Different parameter data types, different number of parameters, different order of parameters.

Description : Define what is the difference between CONST and READONLY?

Last Answer : Both are meant for constant values. A const field can only be initialized at the declaration of the field. A read-only field can be initialized either at the declaration or.

Description : Define what is smart navigation?

Last Answer : The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.

Description : Define what does a break statement do in switch statements?

Last Answer : The break statement terminates the loop in which it exists. It also changes the flow of the execution of a program. In switch statements, the break statement is used at the end of a case ... break statement is mandatory in C# and it avoids the fall through of one case statement to another.