Difference between String vs. String builder
String - Once the string object is created, its length and content cannot be modified. This method is slower.
String builder - Once the object is created, it can able to modify length and content. This method is faster.
Example on String vs. String builder
namespace stringvsstringbuilder
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("String Example");
string str = string.Empty;
DateTime start = DateTime.Now;
Console.WriteLine("Start time" + start.ToString());
for (long i = 0; i < 100000; i++)
{
str += i.ToString();
}
DateTime stop = DateTime.Now;
Console.WriteLine("Start time" + stop.ToString());
Console.WriteLine("StringBuilder Example");
StringBuilder builder = new StringBuilder();
start = DateTime.Now;
Console.WriteLine("Start time:" + start.ToString());
for (long i = 0; i < 100000; i++)
{
builder.Append(i.ToString());
}
stop = DateTime.Now;
Console.WriteLine("Stop time:" + stop.ToString());
Console.Read();
}
}
}
Table of Content
- Abstract Classes
- Access Specifiers
- ASP.NET 2.0 Interview Questions
- Assembly and Namespaces
- Authentication in .Net
- Authorization in .Net
- Boxing vs Unboxing
- Const vs Read-only
- Const vs Read-only
- Constants in .Net
- Constructors
- Constructors of Extended Classes
- Cursor point to TextBox
- Data Abstraction
- Data Encapsulation
- Destructors
- Example on Encapsulation
- Fields in .Net
- Focus method
- Function Overloading
- Garbage Collections
- Gridview with Paging
- Indexers in .Net
- Inheritance and Extended Classes
- Inheritance in .Net
- Inheritance n Extended Classes
- Members of a Class
- Methods and Events
- Namespace used in EventLog
- Object
- Overriding and Hiding
- Page Life Cycle
- Properties in .Net
- Ref vs Out parameter
- Server.transfer vs Response.redirect
- Signatures of Main[] fn
- State Management
- String vs String Builder
- Types of parameters
- Using Keyword
- Value type vs Ref type
- Versioning in .Net
- What are Class Methods
- What are Classes
- What are Constructors
- What are Delegates
- What are Objects
- What is View State
- When to OverLoad
Thursday, May 27, 2010
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment