Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7522527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:32:57+00:00 2026-05-30T02:32:57+00:00

I looked previous questions but it didn’t help. I have a very simple function

  • 0

I looked previous questions but it didn’t help.
I have a very simple function written in c#.
It give me compiler error “Use of unassigned local variable ‘linea’ ” (line (2)).
What could be wrong? And could tell me how to correct it please?

    public void llenarTabla()
    {

        int idx;
        string[] linea; (1)
        for (idx = 0; idx < numListas; idx++)
        {
            linea[0] = Convert.ToString(idx); // (2)
            switch(OrdenListas[idx]){
                case 0: linea[1] = "Crescente"; break;
                case 1: linea[1] = "Decrescente"; break;
                case 2: linea[1] = "Aleatorio"; break;
                default: linea[1] = "No especificado" ; break;
            }
            linea[2] = Convert.ToString(LongitudListas[idx]);
        }
    }

I already saw the reference “Compiler error if a variable is used but it might be not initialized. But as far I see the variable string[] (indexes:0,1,2) is inizialized in every case except numlistas = 0 (numlistas is a class parameter and its value is supposed to be >=1).

I also tried to change line (1) and (2) to:

(1) List<string> linea;

(2) linea.Add(Convert.ToString(idx));

but same error (when I tried to change line (1) and (2) I put as a comment all the following lines.

Thank you in advance for every help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:32:58+00:00Added an answer on May 30, 2026 at 2:32 am

    Just do:

    string[] linea = new string[3];//3 is the length of your array
    //you can store 3 elements in linea [0] [1] and [2]
    

    See MSDN reference for arrays in C#

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've looked but didn't find previous questions specific enough, so sorry if this is
I have looked through as many previous questions as possible but never saw a
I looked into previous questions, but they didn't seem to answer what's happening to
I looked through previous questions to this effect, but my situation is slightly different...
I've looked through previous questions and none of them have really worked for me,
I have looked at previous questions and nothing seems to fit what I require.
Following one of my previous questions I have started to get a error with
I looked at previous post based on this but they do not relate. I
Still a mysql newb and I looked extensively through previous questions trying to find
I've looked at a lot of the previous questions asked about sharepoint and accessing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.