Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Is string reference type / value type?

Answers were Sorted based on User's Feedback



Is string reference type / value type?..

Answer / guest

Simple types (such as float, int, char), enum types and
struct types are all value types.
Note that many types (such as string) appear in some ways
to be value types, but in fact are reference types. These
are known as immutable types

Is This Answer Correct ?    18 Yes 0 No

Is string reference type / value type?..

Answer / ravikiran gullapalli

String is 100% Reference Type. It is an immutable object.

Is This Answer Correct ?    18 Yes 0 No

Is string reference type / value type?..

Answer / mukkamalla prasastha

if u dont know dont confuse others
String is 100 % reference type

Is This Answer Correct ?    17 Yes 0 No

Is string reference type / value type?..

Answer / k.hemalatha

string is a reference type but behave likes value type.

Is This Answer Correct ?    16 Yes 2 No

Is string reference type / value type?..

Answer / abhit

String is reference type.

Is This Answer Correct ?    14 Yes 1 No

Is string reference type / value type?..

Answer / kapil dalke

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

Is This Answer Correct ?    14 Yes 2 No

Is string reference type / value type?..

Answer / n

Hi Guys

If any of you got so far.. Here is the deal:

The differnce between value types and reference types are
whether the information is stored in the stack or on the
heap. Design guidelines for designing structures (value
type, stored in the stack) is that it's instance value
should be less than 16 bytes.

In the .NET Framework, ALL value types are 16 bytes or
shorter.

A string can be a lot more than 16 bytes...

It does however act like a value type in order to make the
programming easier for us... This can be the reason for all
this confusion...

Now stop arguing and start converting coffee into code....

/N

Is This Answer Correct ?    14 Yes 2 No

Is string reference type / value type?..

Answer / akn

Everything not derived from System.ValueType is a reference
type.
So System.String is reference type.

Is This Answer Correct ?    11 Yes 0 No

Is string reference type / value type?..

Answer / ak

How do you explain this then?

public void MyTest()
{
Program myClass = new Program();
myClass.value = 1;
Console.Out.WriteLine(myClass.value.ToString
()); //1
Program newClass = myClass;

newClass.value = 2;
Console.Out.WriteLine(myClass.value.ToString
()); //2


myClass.strvalue = new String("1".ToCharArray
());

Console.Out.WriteLine(myClass.strvalue); //1
newClass.strvalue = myClass.strvalue;

newClass.strvalue = "2";
Console.Out.WriteLine(myClass.strvalue); //2
}

Is This Answer Correct ?    4 Yes 0 No

Is string reference type / value type?..

Answer / n.

There is no magic.... You can test all the types:

using System;
using System.Collections.Generic;
using System.Text;

namespace List_Value_Types
{
class Program
{
static void Main(string[] args)
{
SByte a = 0;
Byte b = 0;
Int16 c = 0;
Int32 d = 0;
Int64 e = 0;
string s = "";
Exception ex = new Exception();

object[] types = { a, b, c, d, e, s, ex};

foreach (object o in types)
{
string type = "";
if (o.GetType().IsValueType)
type = "Value type";
else
type = "Reference type";

Console.WriteLine("{0}: {1}", o.GetType(),
type);
}
Console.ReadKey();
}
}
}

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More C Sharp Interview Questions

Indexers in c#?

8 Answers   Intaglio, Microsoft, TCS,


use of operator overloading of implicit & explicit operators?

1 Answers   TCS,


What is type safe code?

0 Answers  


What?s the difference between <c> and <code> XML documentation tag?

1 Answers  


Why main is static in c#?

0 Answers  


Why do we Need of static class in c#?

0 Answers   NA,


When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)?

1 Answers  


What do you mean by casting a data type?

0 Answers  


What are the 2 broad classifications of data types available in c#?

0 Answers  


What is short circuit logical evaluation?

1 Answers   TCS,


What is an icollection in c#?

0 Answers  


How we can create an array with non-default values?

0 Answers  


Categories