What’s the advantage of using System.Text.StringBuilder over System.String? 

1 Answer

Answer :

StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it’s being operated on, a new instance is created.

Related questions

Description : What’s the advantage of using System.Text.StringBuilder over System.String?

Last Answer : StringBuilder is more efficient in cases where there is a large amount of string manipulation. Strings are immutable, so each time a string is changed, a new instance in memory is created.

Description : What’s the advantage of using System.Text.StringBuilder over System.String?

Last Answer : StringBuilder is more efficient in cases where there is a large amount of string manipulation. Strings are immutable, so each time a string is changed, a new instance in memory is created. 

Description : What’s the difference between System.String and System.Text.StringBuilder classes?

Last Answer : System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.

Description : What’s the difference between System.String and System.Text.StringBuilder classes?

Last Answer : System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.

Description : What’s the difference between System.String and System.StringBuilder classes?

Last Answer : System.String is immutable, System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.

Description : Define what is the difference between string keyword and System. String class?

Last Answer : String keyword is an alias for System. String class. Therefore, the System. String and string keyword are the same, and you can use whichever naming convention you prefer. The String class provides many methods for safely creating, manipulating, and comparing strings.

Description : Briefly explain how to convert a string representation of a number to a numeric type, such as an Integer or a Double.

Last Answer : All numeric data types have a Parse method that accepts a string parameter and returns the value represented by that string cast to the appropriate data type. You can use the Parse method of each data type to convert strings to that type.

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

Last Answer : The database name to connect to. 

Description : How can you implement a mutable string? 

Last Answer : System.Text.StringBuilder 

Description : Name a few string properties.

Last Answer : trim, tolower, toupper, concat, copy, insert, equals, compare. 

Description : Is string Unicode, ASCII, or something else? 

Last Answer : Unicode

Description : string is an alias for what?

Last Answer : System.String 

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

Last Answer : The database name to connect to.

Description : C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write? 

Last Answer : Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write one yourself, even if there’s no implementation in it.

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

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

Description : Describe the general procedure for rendering text to a drawing surface.

Last Answer : You must first obtain a reference to a Graphics object. Next, create an instance of a GraphicsPath object. Use the GraphicsPath.AddString method to add text to the GraphicsPath. Then, call the Graphics.DrawPath or Graphics.FillPath to render the text.

Description : What’s the .NET collection class that allows an element to be accessed using a unique key? 

Last Answer : HashTable. 

Description : What’s the .NET collection class that allows an element to be accessed using a unique key?

Last Answer : HashTable.

Description : Briefly discuss the advantages and disadvantages of using typed DataSet objects.

Last Answer : Typed DataSet objects allow you to work with data that is represented as members of the .NET common type system. This allows your applications to be aware of the types of data returned in a DataSet and serves ... if you do not know the structure of your data, and can be used with any data source. 

Description : How would you read and write using the console?

Last Answer : Console.Write, Console.WriteLine, Console.Readline 

Description : What is the using statement for?

Last Answer : The using statement defines a scope at the end of which an object will be disposed.

Description : Write some code using interfaces, virtual methods, and an abstract class.

Last Answer : using System; public interface Iexample1 { int MyMethod1(); } public interface Iexample2 { int MyMethod2(); } public abstract class ABSExample : Iexample1, Iexample2 { public ABSExample( ... override void VIRTMethod2() { System.Console.WriteLine("VIRTMethod2 has been overridden"); } }

Description : Is using of exceptions in C# recommended?

Last Answer : Yes, exceptions are the recommended error handling mechanism in .NET Framework.

Description : Why use “using” in C#?

Last Answer : “Using” statement calls – “dispose of” method internally, whenever any exception occurred in any method call and in “Using” statement objects are read-only and cannot be reassignable or modifiable.

Description : Give an example of using a sealed class in C#?

Last Answer : Below is the sample code of sealed class in C# - class X {} sealed class Y : X {} Sealed methods - class A { protected virtual void First() { } protected virtual void Second() { } } ... inherits from class B then method - First will not be overridable as this method is sealed in class B.

Description : Can you allow a class to be inherited, but prevent the method from being over-ridden?

Last Answer : Yes. Just leave the class public and make the method sealed. 

Description : Can you allow a class to be inherited, but prevent the method from being over-ridden?

Last Answer : Yes. Just leave the class public and make the method sealed. 

Description : But won't most .NET developers eventually choose C# over Visual Basic.NET? 

Last Answer : No. Because the power of the two languages is so similar, the primary factor for developers migrating to the .NET world will probably be the syntax they prefer. Since many more developers ... the dominant language for building Windows applications five years from now will still be Visual Basic. 

Description : What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?

Last Answer : The first one performs a deep copy of the array, the second one is shallow. 

Description : What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?

Last Answer : The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a ... create a new instance of each element's object, resulting in a different, yet identacle object.

Description : Where’s global assembly cache located on the system ?

Last Answer : Answer: Usually C:\winnt\assembly or C:\windows\assembly.

Description : Can you store multiple data types in System.Array?

Last Answer : No. 

Description : Why are there five tracing levels in System.Diagnostics.TraceSwitcher?

Last Answer : The tracing dumps can be quite verbose. For applications that are constantly running you run the risk of overloading the machine and the hard drive. Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.

Description : Can you store multiple data types in System.Array?

Last Answer : No.

Description : Why are there five tracing levels in System.Diagnostics.TraceSwitcher? 

Last Answer : The tracing dumps can be quite verbose. For applications that are constantly running you run the risk of overloading the machine and the hard drive. Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.

Description : Can you store multiple data types in System.Array?

Last Answer : No.

Description : Mention the assembly name where System namespace lies in C#?

Last Answer : Assembly Name – mscorlib.dll

Description : Whats an assembly ?

Last Answer : Answer: Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is ... implementations. To the runtime, a type does not exist outside the context of an assembly.

Description : What’s a strong name ?

Last Answer : Answer: A strong name includes the name of the assembly, version number, culture identity, and a public key token.

Description : What’s the difference between private and shared assembly? 

Last Answer : Answer: Privateassembly is used inside an application only and does not have to be identified by a strong name. Shared assembly can be used by multiple applications and has to have a strong name.

Description : What’s the difference between the Debug class and Trace class? 

Last Answer : Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.

Description : What’s the difference between // comments, /* */ comments and /// comments?

Last Answer : Single-line comments, multi-line comments, and XML documentation comments.

Description : What’s a multicast delegate?

Last Answer : A delegate that has multiple handlers assigned to it. Each assigned handler (method) is called. 

Description : What’s a delegate? 

Last Answer : A delegate object encapsulates a reference to a method. 

Description : What’s the implicit name of the parameter that gets passed into the set method/property of a class?

Last Answer : Value. The data type of the value parameter is defined by whatever data type the property is declared as.

Description : What’s the difference between an interface and abstract class?

Last Answer : Answer: An abstract class and Interface both have method only but not have body of method.The difference between Abstract class and An Interface is that if u call Ablstract class then u have to call ... type, Parameter type, Parameter Number all must be same . Only body of method can change. 

Description : What’s an abstract class?

Last Answer : Answer:Classes that cannot be instantiated. We cannot create an object from such a class for use in our program. We can use an abstract class as a base class, creating new classes that will inherit from ... can inherit from a non-abstract class. In C++, this concept is known as pure virtual method.

Description : What’s the C# syntax to catch any possible exception?

Last Answer : A catch block that catches the exception of type System.Exception. You can also omit the parameter data type in this case and just write catch {}.

Description : What’s the top .NET class that everything is derived from?

Last Answer : System.Object.

Description : What’s the difference between camel and pascal casing?

Last Answer : PascalCasing, camelCasing