Related Posts Plugin for WordPress, Blogger...

About

Follow Us

Showing posts with label string. Show all posts
Showing posts with label string. Show all posts

Wednesday, 24 June 2015

String in Javascript:

The javascript string is an object which represents sequence of character.

We can create string in javascript in two ways:

1.      Using String Literal
2.      Using String object

1.      Using String literal: syntax to create string using string literal:
Var newstr= “This is string”;

Example:
<script>
        var newstr = "this is new string";
        document.write(newstr);
    </script>

2.     Using String Object:

Syntax to create new string using string object as given below:

Var newstr= new String(“new string”);

Example:
    <script>
        var newstr = new String("this is new string");
        document.write(newstr);

    </script>

Tuesday, 19 May 2015

In this article I will explain the  difference between string and stringbuilder in c#.

String

String is immutable object  (i.e.  once created cannot be changed ) and It always create new object of string type in memory.  If we want to append or replace something in string then it will discard the old value and will create new instance in memory to hold the new value. String belongs to “System” namespace.

 Example

 string   str = "Hello Visitor";
 // create a new string instance instead of changing the old one
 str += "How Are";
 str += "You ??";

 Stringbuilder

 StringBuilder is mutable, means if create string builder object then you can make modification in the data i.e. you can append and replace the string  without creating new instance for every time.it will update string at one place in memory doesn’t create new space in memory. Stringbuilder belongs to “System.Text”  namespace.

Example:

StringBuilder strbuilder = new StringBuilder("");
strbuilder.Append("Hello");
strbuilder.Append("Visitor ");
string str = sb.ToString();




Please mention in the comments in case you have any doubts related to the post: difference between string and stringbuilder.

Wednesday, 11 March 2015

String and StringBuilder class are used to handle the strings but there are many differences between these two, regarding their use and namespace to which they belong.
In this article I will explain the difference between String and StringBuilder class in ASP.NET with C# and When to use String and when to use StringBuilder and why?

Tuesday, 17 February 2015

Now in this article I will show the selected items/values from the CheckBoxList in comma-separated string.In the design file(.aspx)  place a CheckBoxList and place two buttoncontrols and a label control as given below: