C# - What Is The Difference Between Xxx.tostring() And (string)xxx

Jan 24, 2011

whats the difference in the two string methods below?

string str1 = dr["RAGStatusCID"].ToString();
string str2 = (string)dr["Description"];

View 7 Replies


Similar Messages:

Web Forms :: Difference Between .ToString And Convert.To String?

Dec 10, 2010

I want to Know What is the difference between .ToString and Convert.To string?

View 4 Replies

Null Reference Using .toString / Convert The Object ConnString (a Connection String) Into A String?

Feb 13, 2010

on VWD 2005 this code works fine, but on 2008 it says I haven't created an instance of the object. I want to convert the object connString (a connection string) into a string.

'This acceses the virtual directory web.config file for connection strings
'We have to convert the object to a connection string
Dim rootWebConfig As System.Configuration.Configuration
rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/VirtualDirec")
Dim connString
As System.Configuration.ConnectionStringSettings
connString = rootWebConfig.ConnectionStrings.ConnectionStrings("ConnectString1")
Dim strConnString
As
String = connString.ToString().......

View 5 Replies

C# - .ToString(), (string), Or As String. When To Use What

Feb 10, 2011

I ran into a bug that was bothering me. I had JObject that I thought would be fine with

obj["role"].ToString()

The string was there and everything. A final resort was to change to a

(string)obj["role"]

just to see what happens and it works. My question is how do I know when to use a .ToString() as opposed to a (string) as opposed to an "as String".

View 3 Replies

What Is The Difference Between String (S Capital) And String (s Small)

Jan 4, 2011

What is the difference between

String (S capital)

and

string (s small)

Where to use String and where string?

View 6 Replies

What Is Difference Between Two Data Types String

Dec 25, 2010

Both of these used same function. So why these two have been provided?

Secondly Why there is Not a constructor like:

String abc=new String("Hello");

View 2 Replies

How To Format DateTime.ToString

Feb 5, 2010

How to format DateTime.ToString(????)Result should look like: 2010-02-05T10:36:26+10:00

View 2 Replies

C# - ToString() Format Is Not Working?

Nov 29, 2010

I've a strange problem. We use Dutch and French lanuage on our site (nl-NL / fr-FR)I'm binding to a gridview and the strange thing is, the numeric value-saparator (dot) is not displaying well for French (fr-FR)ASP.NET

protected void gridview_RowDataBound(object sender, GridViewRowEventArgs e)
{
Label lbla_min_10 = new Label();

[code]...

View 4 Replies

C# - XElement.ToString() Causes System.OutOfMemoryException?

Nov 25, 2010

I have an XElement object that contains about 120MB of data. The XML consists of approx 6000 elements of about 20kb each.

I am trying to call XElement.ToString() as I need to return the OuterXml in a webservice.

I am getting a System.OutOfMemoryException.

System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown:

at System.String.GetStringForStringBuilder(String value, Int32 startIndex, Int32 length, Int32 capacity)
at System.Text.StringBuilder.GetNewString(String currentString, Int32 requiredLength)
at System.Text.StringBuilder.Append(Char[] value, Int32 startIndex, Int32 charCount)
at System.IO.StringWriter.Write(Char[] buffer, Int32 index, Int32 count)
at System.Xml.XmlEncodedRawTextWriter.FlushBuffer()
at System.Xml.XmlEncodedRawTextWriter.WriteAttributeTextBlock(Char* pSrc, Char* pSrcEnd)
at System.Xml.XmlEncodedRawTextWriter.WriteString(String text)
at System.Xml.XmlEncodedRawTextWriterIndent.WriteString(String text)
at System.Xml.XmlWellFormedWriter.WriteString(String text)
at System.Xml.XmlWriter.WriteAttributeString(String prefix, String localName, String ns, String value)
at System.Xml.Linq.ElementWriter.WriteStartElement(XElement e)
at System.Xml.Linq.ElementWriter.WriteElement(XElement e)
at System.Xml.Linq.XElement.WriteTo(XmlWriter writer)
at System.Xml.Linq.XNode.GetXmlString(SaveOptions o)
at System.Xml.Linq.XNode.ToString()

I have the same data in an XmlDocument and can call XmlDocument.OuterXml without a problem. I can also call XElement.Save() to save the XML to a file without a problem.

View 2 Replies

Web Forms :: Datetime.now.tostring() Two Different Time

Nov 11, 2010

I have deployed my asp.net application in my hosting provider they are from US... I have one filed in which i have wriiten Datetime.now.tostring() it saves in Database table it save 11/11/2010 5:20:47 AM

View 17 Replies

Security :: MembershipUser.ProviderUserKey.ToString?

Mar 20, 2011

When I run the following debugging code it writes out credits:0

Dim MembershipUser As MembershipUser = Membership.GetUser()
Dim UID As String = MembershipUser.ProviderUserKey.ToString
SQL = "SELECT SUM(Credits) As Credits FROM Credits WHERE " & _
"DateDiff(m, [DateTime], GETDATE()) < 6 AND [UserID]=@UserID;"
cmd = New SqlCommand(SQL, Conn)
cmd.Parameters.Add(New SqlParameter("@UserID", UID))
DataReader = cmd.ExecuteReader()
If DataReader.HasRows Then
Do While DataReader.Read

[Code]....

View 4 Replies

Update Gridview - Use SelectedDataKey.Value.ToString() To Get Datakey?

Sep 2, 2010

after my grid view updates a record I would like to run some code, I have tried to use SelectedDataKey.Value.ToString() to get the datakey. However it is null, the record updates so the value must be stored somehow?

View 1 Replies

Web Forms :: Unable To Get The Page Title With ToString

Feb 23, 2010

BookmarkA.Title = Me.head.Page.Title.ToString()

I tried the above one in order to get the page title but I failed ! What I need to do ?

Me.head.Page.Title.ToString() did't get the value !

View 4 Replies

Security :: User.Identity.Name.ToString() Is This Secure And How To Store It

Feb 10, 2010

I have created an asp.net site with anonymous access turned off. Its for an internal (intranet) system which uses User.Identity.Name.ToString() to get the users login windows ID and then displays some records from a datagrid depending on their login ID. Is this secure? Also i am struggling to workout how best to store the result of User.Identity.Name.ToString() as I am not keen on storing it in a hidden text field and would rather not call it all the time unless this is the best way?

View 3 Replies

Response.Output.Write(myReader[...].ToString) To 2 Columns?

May 14, 2010

Well, I'm working with

Response.Output.Write(myReader[...].ToString)

and I'd like to output the data in 2 columns.

For instance the dataReader gets the following data: "1", "2", "3", "4" which will result in

1

2

3

4

but I'd like to have it like (in columns)

1 | 2

3 | 4

The Html code would be like

[Code]....

it would result in something like

[Code]....

But I'm working with an array that supplies the DataReader with what it should read, so I cannot write the code as above.

foreach (string strArr in outputLst)

View 12 Replies

Localization :: DateTime.Now.ToString To Display In 24 Clock Mode?

Oct 25, 2010

I have a situation where I need to display the time in 24hr clock mode rather than 12hr mode. Is there a way to do this?

I need it to just display the the Hours & Mins e.g. 13:42. AM or PM is optional.

View 1 Replies

Web Forms :: Server.UrlDecode(Request.Form.ToString ())?

Mar 23, 2011

I have a web page which has few comments box which multi line asp text boxes. When i submit the page, i pass all the data as Server.UrlDecode(Request.Form.ToString()). Before submitting it to DB and splitting the string based on & and manipulating the values.
But when the user types in & in the comment box, my string manipulation gets messed up and i am getting "Index outside the bound" error.

Is there any way to encode user typed & and manipulate it?

View 9 Replies

Web Forms :: Check If The Text.ToString() Value Is Parseable To Integer Value?

Apr 19, 2010

I have a text box in which one is supposed to Enter a number .But if a person enters Text I get errors when parsing to integer.

View 4 Replies

Configuration :: Migrating The Request.UrlReferrer.ToString() To The Web.config File

Jan 10, 2011

I have the following code in 'main.cs' file where I am checking for a condition

protected void Page_Load(object sender, EventArgs e)
{
if (Request.Form.Get("task") != null && Request.Form.Get("postToURL") != null &&
Request.UrlReferrer.ToString().Substring(0, 31).Equals("http://cs.astra.co.in:4040"))
{
ASCIIEncoding encoding = new ASCIIEncoding();
<SO ON>

Instead of checking for the URL [URL] in 'main.cs', Can I check for the same condition in the 'web.config' file ? If so, How can I do that ?? Is there any way to transfer the part -- Request.UrlReferrer.ToString().Substring(0, 31).Equals[URL] -- into the 'web.config' !!

[Code]....

View 1 Replies

AJAX :: MSAJAX BUG: Overrides Of ToString () And Other Methods Present In Object Do Not Propagate To Derived Classes?

Oct 8, 2010

MSAJAX: overrides of toString() and other Object methods do not propagate to derived classes

View 1 Replies

Security :: FormsAuthentication.SetAuthCookie(Session["UserSession"].ToString(), False)?

Jul 22, 2010

What is the use of FormsAuthentication.SetAuthCookie(Session["UserSession"].ToString(), false);

View 1 Replies

DataSource Controls :: Fails At Rdr = Cmd.ExecuteReader(); And Also Fail At ZipCodes.Add(rdr["h.*"].ToString());?

Feb 25, 2010

Im trying to take the example from this website http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/sql-server-2008-proximity-search-with-th and make it work on my site. Its this part im having troubles with

[Code]...

here is my code from my function that doesnt work.

[Code]...

Any suggestions on how to get it to work? it fails at rdr = cmd.ExecuteReader(); im also worried it will also fail at ZipCodes.Add(rdr["h.*"].ToString());

View 2 Replies

What Is The Difference Between "" And " " - For Which One Can Use String.Empty

Sep 23, 2010

What is the difference between "" and " " For which one i can use string.Empty.

View 2 Replies

DateTime - ToString() Display Meridiem As "A.M." Or "P.M."

Feb 2, 2010

Is there any way to use the DateTime.ToString() method to display the meridiem of the time portion as "A.M." instead of "AM"? I tried using the mask "t.t." but this just outputs "A.A."

View 2 Replies

State Management :: How To Pass Dynamic String Through Query String With Java Script

Dec 24, 2010

I m facing some problem. i m not passing Dynamic string through query string..

I m using this code

string abc = "CPCB_" + TextBox1.Text + "_" + TextBox2.Text;

Response.Write("<script>window.open('xml.aspx?Flag=3&date='+abc,target='new');</script>");

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved