.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> C# >> Post New Question Subscribe to Interview Questions

Is String a primitive type?

Posted By :Ravi Ranjan Kumar     Posted Date :July 24, 2011    Points :40   Category :C# 
No, the string is not a primitive type.
However, it has some characteristics common with the primitive types.
The language supports string literals in the code, so that you don't have to explicitly create Stringinstances using the new keyword to get a string object.
There is also support for concatenating strings using the + operator, which the compiler turns into a call to the String.Concat method.
Strings are immutable, which means that it in most situations has value type semantics, just like the primitive types.


You can also find related Interview Question to Is String a primitive type?  below: 

How do I convert a numeric type to a string?

  
Call Sytem.Object.ToString(). For example, if the variable count is an integer, write the following:
string text = count.ToString(); (More...)

How do I call a member method and pass a primitive type (Value Type) by reference?

  
Use the ref keyword when declaring the parameter of the method, for example:

public bool GetValue( ref int returnValue );

This will pass the numeric by reference.You can modify the value of returnValue within the body of GetValue and it will persist when the method call returns. (More...)

Is string reference type / value type?

  
string is reference type
because String is immutable objects..........
means does not change the values(string)....... (More...)

Why string are called Immutable data Type ?

  
The memory representation of string is an Array of Characters, So on re-assigning the new array of Char is formed & the start address is changed . Thus keeping the Old string in Memory for Garbage Collector to be disposed. (More...)

Why string are called Immutable data Type ?

  
The memory representation of string is an Array of Characters, So on re-assigning the new array of Char is formed & the start address is changed . Thus keeping the Old string in Memory for Garbage Collector to be disposed. (More...)

How do you declare a Numeric type to String?

  
Call System.Object.Tostring()
For Example
int idx =0;
string str - idx.ToString();
(More...)

How do you declare a Numeric type to String?

  
Call System.Object.Tostring()
For Example
int idx =0;
string str - idx.ToString(); (More...)

Difference between type constructor and instance constructor? What is static constructor, when it will be fired? And what is its use?

  
(Class constructor method is also known as type constructor or type initializer)
Instance constructor is executed when a new instance of type is created and the class constructor is executed after the type is loaded and before any one of the type members is accessed. (It will get executed only 1st time, when we call any static methods/fields in the same class.) Class constructors are used for static field initialization. Only one class constructor per type is permitted, and it cannot use the vararg (variable argument) calling convention. (More...)

What is type safe?

  
Type safety is about increasing the opportunities for the compiler to detect your coding errors. If you use interfaces instead of delegates the compiler will have more opportunities to detect your coding errors. (More...)

What is type system unification?

  
The goal of type system unification is to bridge the gap between value types and reference types that exists in most languages. For example, a Stack class can provide Push and Pop methods that take and return object values.

public class Stack
{
public object Pop() {...}
public void Push(object o) {...}
}
Because C# has a unified type system, the Stack class can be used with elements of any type, including value types like int. (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend