.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

why do we use cint,tostring,toint32

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :Windows Application
many times i was not getting correct output,then i put .tostring() at the end then it gave good output.so basically why do v need this?
also Convert.ToInt32(cmd.ExecuteScalar()) why convert to int32?

View Complete Post

More Related Resource Links


 How do I remove 'convert.ToInt32' found in the listed C# Code - below, then, replace with the following VB string code:Public Function strLong(ByVal pstrText As String) As String '// Extract just the 0-9 chars from a string Dim strTemp As String Dim lngI As Long strTemp = "" For lngI = 1 To Len(pstrText) If InStr(1, "1234567890", Mid$(pstrText, lngI, 1)) > 0 Then strTemp = strTemp & Mid$(pstrText, lngI, 1) End If Next lngI strLong = Left(strTemp, 20) End Function ' strLong C# Code:protected void Page_Load(object sender, EventArgs e) { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["sqlapplicationConnectionString"].ToString()); try { SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "INSERT INTO Application (" + " First, Last, City, State)" + ") VALUES (" + " @First, @Last, @City, @State"; cmd.Parameters.AddWithValue(new SqlParameter() { ParameterName = "@First", SqlDbType.NVarChar, Value = Convert.ToInt32(Request["First"]) }); cmd.Parameters.AddWithValue(new SqlParameter()

Showing positive/negative sign in the output of Int32.ToString(string)

Hi,   Now this may be really simple but I'm unable to make it work or find it in MSDN. What is the format specifier for showing +/- sign of an Int32? I have tried "+0", "-0" and "+-0" and all of them give wrong results for either positive or negative or both kind of values. Note: The specifier should return "+0" for 0.

Features of ToString() and GetType()

Write about the features of the above two methods in C#? I need some features of the above methods to complete my exam preparation.

(int) vs Convert.ToInt32


I am fairly new to C# and in fact to .NET as a whole.  I have seen that you can cast datatypes by using the (<datatype>) prefix when you assign the data to a variable or whatever.

I have also seen that there is a Convert.<ToDataType> method that can be used.

I would like to know when it is best to use each of these and the differences between them.


string str = int.ToString() actually cause postback ??


I've come across an argument that, whether int.ToString() method cause Boxing in following case:

int varInt = 123;

string varStr = varInt.ToString();

Please give some light on this issue. Let me know the internal processing of INTEGER.ToString() function, if any of you knows.


DateTime.ToString("h") not working

I have a situation in which I want to get the hour component of a DateTime,
but I want the 12-hour value that would go with an AM/PM. The only way I
could find to do this was to use a date format string. Since h is the format
character used for this, I figured I would use the method:


However, this would give me an error. But when I used it with a space and
trimmed it:

..ToString("h ").Trim()

It would work fine. Why am I not allowed to use "h" as a format string?
Nathan Sokalski

CInt and Int32 conversion problem


in the codebehind I gave a line gives always zero eventhough textbox1 is not null or zero. I type a number but it return zero...when I try Int32.Parse also it does not work and gives "Input string was not in a correct format." error.please help...




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


MSAJAX: overrides of toString() and other Object methods do not propagate to derived classes
In a class hierarchy built with MSAjax we seem to be unable to propagate an override of toString and other methods found in Object down to derived classes.
My idea is to have a parent class which overrides toString() and then have derived classes that would inherit the toString implementation from the parent. Here's a repro:

how to you get the Handle.ToInt32 of a wpf control?

how to you get the Handle.ToInt32 of a wpf control?

need examples of how to use: ToString method, and Copy methods


Hi.  I'm new to Visual Studio 2008 and this is my first time using the forum.  Could someone give me examples of how to use the ToString(), Copy()?  I know how to use the "ToLower() which converts the current string to lower case.  I would code:

Dim str1 As String = "Hello World!"
Dim str2 As String = str1.ToLower()

Result: str2 contains "hello world!"

I only need to have examples of how I would code the two methods mentioned above.  Thanks you inadvance

Lookup field - toString()


When i use the toString() method on a lookup field i get a string in the form:

Is there a way (a command) to get only the name?

StringBuilder.ToString() Throws a System.ArgumentOutOfRangeException Index was out of range


I have the following code to show a logging window that has the last 64000 chars of code. Every new line I add the first line will be deleted:

m_sbText = new StringBuilder(65000);

private void AddLine(string LogMessage)
   if (m_sbText.Length > 64000)
      m_sbText.Remove(0, m_sbText.ToString().IndexOf("\n") + 1);
   textBoxLog.Text = m_sbText.ToString();

When I let this run the first time I got an OutOfMemory exception because I forgot to add

textBoxLog.UndoLimit = 0;

So this UndoLimit problem is still happening in WPF dot net framework 4. 

I added the UndoLimit and let this run for a night. Once every few hours the textBoxLog.Text = m_sbText.ToString(); line raises a System.ArgumentOutOfRangeException Index was out of range exception on StringBuilder.ToString(). Because I do not do anything with the Index I suspect the StringBuilder to mess up internal indexes.

Error : Cannot convert method group 'ToString' to non-delegate type 'int'.

Ive gotten this error to my underlined line(bold): Cannot convert method group 'ToString' to non-delegate type 'int'. 
How do i Solve it??

 protected void GridView1_SelectedIndexChanged1(object sender, EventArgs e)

        Label2.Visible = true;
        SqlConnection conn = new SqlConnection("Data Source= EN12-2-20-PC02\\SQLEXPRESS;" + "Initial Catalog=ssms;Integrated Security=SSPI");

        DataSet ds = null;
        ds = new DataSet();
        int timestamp = 0;
        timestamp = GridView1.SelectedDataKey.Value.ToString;

        SqlDataAdapter da = null;
        string mySQL = null;
        mySQL = "SELECT timestamp from loginHistory where username = '" + lblShowUser.Text + "'";
        da = new SqlDataAdapter(mySQL, conn);
        da.Fill(ds, "loginHistory");
        DataSet dsSel = new DataSet();

        GridView1.DataSource = dsSel;

TextBlock Text not refreshed after raising PropertyChanged - object instance the same, ToString() re



I am working with an object that handles localized strings.  The object type (LocalizedString) provides the correct localized string in its ToString() method.

I have a view model that exposes a property of type LocalizedString.  When my current thread and ui culture is changed, I raise the property changed event for this property, however the strings in the UI do not get updated.

I narrowed it down some to discover that it stops working after the value has been read from the property once.  If instead of just raising property changed when the culture changes I do this:


LocalizedString temp = MyProperty;
MyProperty = null;
MyProperty = temp; // <-- property changed gets raised in the setter 


It seems to work.  The only difference is that the LocalizedString object instance changed.

Basically I believe what happens is this:  The dependency property (TextBlock.Text in this case) gets notified that the bound value has changed.  It goes and retrieves the property value (LocalizedString object), does a comparison and sees that the previous value and the new value are the same object instance, and stops - does not refresh the

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend