I am creating a DLL in C# but I don't understand completely when I should use a string variable or a StringBuilder object in this situation. I want to hold a variable that is a string and be able to update it and retrieve it via a property of the dll.
Which should I use, a string or a StringBuilder and if possible why?
namespace Mine
{
public class MyDLL
{
private string myString;
public UseString
{
get { return myString; }
set { myString = value; }
}
}
}
OR
namespace Mine
{
public class MyDLL
{
private StringBuilder myString = new StringBuilder();
public UseString
{
get { return myString.ToString(); }
set { myString.Replace(myString.ToString(), value); }
}
}
}
Which should I use, a string or a StringBuilder and if possible why?
namespace Mine
{
public class MyDLL
{
private string myString;
public UseString
{
get { return myString; }
set { myString = value; }
}
}
}
OR
namespace Mine
{
public class MyDLL
{
private StringBuilder myString = new StringBuilder();
public UseString
{
get { return myString.ToString(); }
set { myString.Replace(myString.ToString(), value); }
}
}
}