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 7538311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:05:26+00:00 2026-05-30T07:05:26+00:00

I am new to c# and I don’t understand why this isn’t working. I

  • 0

I am new to c# and I don’t understand why this isn’t working. I want to split a previously splitted string.

My code is the following:

int i;
string s;
string[] temp, temp2;

Console.WriteLine("write 'a-a,b-b,c-c,d-d'";
s = Console.ReadLine();
temp = s.Split(',');

for (i = 0; i < temp.Length; i++)
    temp2[i] = temp[i].Split('-');

I get the following error Cannot implicitly convert type 'string[]' to 'string

I want to end with:

temp = {a-a , b-b , c-c , d-d};
temp2 = {{a,a},{b,b},{c,c},{d,d}};
  • 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-30T07:05:27+00:00Added an answer on May 30, 2026 at 7:05 am

    The result of string.Split() is string[], which you should already see by the correct usage when you assign to string[] temp. But when you are assigning to the elements of string[] temp2, you are trying to store arrays of strings in slots that are meant to only store strings, hence the compiler error. Your code could work with a simple change below.

    string[] temp;
    string[][] temp2; // array of arrays 
    
    string s = "a-a,b-b,c-c,d-d";
    temp = s.Split(',');
    
    temp2 = new string[temp.Length][];
    
    for (int i = 0; i < temp.Length; i++)
        temp2[i] = temp[i].Split('-'); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't want to make a new instance of Form1 in the class, and
Being new to c#, I don't understand how variables are passed between objects. My
I'm new to PHP so I don't know whether this is possible. I need
I'm new to Qt and I don't know how to fix this. I have
I'm new to Scala and don't know Java. I want to create a jar
I don't know if this is a well known 'thing' or something new in
What i want is to open a page in a new tab but don't
If I don't use new to allocate the data members of a class, is
I'm new to nodejs and maybe don't got an event system how it should
I'm new to C# and don't have any programming experience. But I've finish a

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.