error messages about assigning value to string array in c#

  • Thread starter Thread starter Adil1972
  • Start date Start date
A

Adil1972

Guest
Hi

I am learning C#. i dont understand what i am doing wrong in the following code in line 25. i know there are other ways to assign value to str1 string array. but all of them require assigning values one by one to all the elements of array. i want a shortcut like line 25 so that we dont have to write each variable of str1 manually

24) string[,] str1 = new string[2, 4] { { "11", "22", "zz", "ss" }, { "22", "033", "pp", "qq" } };

25) str1 = { { "11", "2", "33", "44"}, { "22", "033", "a", "b"} };

I am getting following error messages

Severity Code Description Project File Line Suppression State
Error CS1002 ; expected helloworld C:\Users\hp\Documents\Visual Studio 2015\Projects\helloworld\helloworld\Program.cs 25 Active
Error CS1002 ; expected helloworld C:\Users\hp\Documents\Visual Studio 2015\Projects\helloworld\helloworld\Program.cs 25 Active
Error CS1002 ; expected helloworld C:\Users\hp\Documents\Visual Studio 2015\Projects\helloworld\helloworld\Program.cs 25 Active
Error CS1002 ; expected helloworld C:\Users\hp\Documents\Visual Studio 2015\Projects\helloworld\helloworld\Program.cs 25 Active
Error CS1002 ; expected helloworld C:\Users\hp\Documents\Visual Studio 2015\Projects\helloworld\helloworld\Program.cs 25 Active
Error CS1002 ; expected helloworld C:\Users\hp\Documents\Visual Studio 2015\Projects\helloworld\helloworld\Program.cs 25 Active
Error CS1002 ; expected helloworld C:\Users\hp\Documents\Visual Studio 2015\Projects\helloworld\helloworld\Program.cs 25 Active
Error CS1002 ; expected helloworld C:\Users\hp\Documents\Visual Studio 2015\Projects\helloworld\helloworld\Program.cs 25 Active
Error CS1002 ; expected helloworld C:\Users\hp\Documents\Visual Studio 2015\Projects\helloworld\helloworld\Program.cs 25 Active
Error CS1525 Invalid expression term '{' helloworld C:\Users\hp\Documents\Visual Studio 2015\Projects\helloworld\helloworld\Program.cs 25 Active

Continue reading...
 
Back
Top