Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Error:Cannot convert type string to int

Error:Cannot convert type string to int

Scheduled Pinned Locked Moved ASP.NET
help
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rockram
    wrote on last edited by
    #1

    Code: foreach(int strAlternative in Suggest(arrWords[iCurrentCount]))-->Error Line { lbSuggestions.Items.Add(new ListItem(strAlternative, strAlternative)); }

    S N 2 Replies Last reply
    0
    • R rockram

      Code: foreach(int strAlternative in Suggest(arrWords[iCurrentCount]))-->Error Line { lbSuggestions.Items.Add(new ListItem(strAlternative, strAlternative)); }

      S Offline
      S Offline
      Sherin Iranimose
      wrote on last edited by
      #2

      what are contents of arrWords? Is it a string array? If yes, 'strAlternative' is also string

      rockram wrote:

      foreach(int strAlternative in Suggest(arrWords[iCurrentCount]))

      I've a confusion with the above line. Is arrWords a double dimension array?

      EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.

      S 1 Reply Last reply
      0
      • S Sherin Iranimose

        what are contents of arrWords? Is it a string array? If yes, 'strAlternative' is also string

        rockram wrote:

        foreach(int strAlternative in Suggest(arrWords[iCurrentCount]))

        I've a confusion with the above line. Is arrWords a double dimension array?

        EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.

        S Offline
        S Offline
        Sutheesh chandran
        wrote on last edited by
        #3

        StrAlternative is an integer

        Sutheesh Ramachandran Cybernet Software Systems, T Nagar, Chennai 17.

        S R 2 Replies Last reply
        0
        • S Sutheesh chandran

          StrAlternative is an integer

          Sutheesh Ramachandran Cybernet Software Systems, T Nagar, Chennai 17.

          S Offline
          S Offline
          Sherin Iranimose
          wrote on last edited by
          #4

          I meant, It should be a string

          EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.

          1 Reply Last reply
          0
          • S Sutheesh chandran

            StrAlternative is an integer

            Sutheesh Ramachandran Cybernet Software Systems, T Nagar, Chennai 17.

            R Offline
            R Offline
            rockram
            wrote on last edited by
            #5

            Hello sir Thanks for your reply Here is my code: using System; using System.IO; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; partial class SpellSuggest : System.Web.UI.Page { private string[] strDictArray; private bool boolDictionaryLoaded = false; private int intErrors = 0; protected void Page_Load(object sender, System.EventArgs e) { int iCurrentCount = 0; string[] arrWords; string strCompleteOriginal = ""; int iWordCount = 0; //string hfOriginalString.Value, hfCurrentCount.Value, hfErrors.Value, hfWordCount.Value; char[] chSplit ={ ' ' }; //string strAlternative = ""; int i = 0; string strText; strText = Request.QueryString["txtContent"]; strText = strText.Trim(); // If nothing to check, exit the procedure if (strText == "") { return; // TODO: might not be correct. Was : Exit Sub } else { // Get the string to check strCompleteOriginal = strText; } // First time the page is loaded if (!IsPostBack) { // Initialize current word index to zero iCurrentCount = 0; // Initialize total word count to zero iWordCount = 0; // Initialize total invalid word count to zero intErrors = 0; // Set value of hidden field containing complete original string to check hfOriginalString.Value = strCompleteOriginal; // Set value of hidden field containing current index hfCurrentCount.Value = "0"; // Split into an array of individual words arrWords = strCompleteOriginal.Split(chSplit); // Count total number of words iWordCount = arrWords.Length; // Set value of hidden field containing total number of words hfWordCount.Value = Convert.ToString(iWordCount); // Set value of hidden field containing total number of invalid words hfErrors.Value = "0"; } else { // Not the first time, split hidden field into an array of individual words arrWords = hfOriginalString.Value.Split(chSplit); // Get index for current word in the array iCurrentCount = Convert.ToInt32(hfCurrentCount.Value); // Get current number of

            1 Reply Last reply
            0
            • R rockram

              Code: foreach(int strAlternative in Suggest(arrWords[iCurrentCount]))-->Error Line { lbSuggestions.Items.Add(new ListItem(strAlternative, strAlternative)); }

              N Offline
              N Offline
              N a v a n e e t h
              wrote on last edited by
              #6

              rockram wrote:

              Suggest(arrWords[iCurrentCount])

              Your method might be returning a string.

              All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia How to use google | Ask smart questions

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups