Cannot convert from 'string' to 'system.collections.generic.list string'

Siva S

I have the two list

  1. nested list of string, and
  2. list in string

In index list, I want to add linesOfContentwith a common value and in-between i want to add separate string ":".

For that i write a code, but, I face a problem "cannot convert from 'string' to 'system.collections.generic.list string'". How to solve this.

int common = 10;
List<List<string>> index = new List<List<string>>();
List<int> linesOfContent = new List<int>();
for(int i = 0; i < 5; i++)
{
      for(int j = 0; j < 5; j++)
      {       
             linesOfContent.Add(i+":"+common);
      }
      index.Add(linesOfContent);
}

Expected Output:

index[0][0] = 0:10
index[0][1] = 1:10
index[0][2] = 2:10

... ...

Robert Columbia

A List of Lists of string should contain Lists of string, not Lists of int.

int common = 10;
List<List<string>> index = new List<List<string>>();
List<string> linesOfContent = new List<string>();
for(int i = 0; i < 5; i++)
{
    for(int j = 0; j < 5; j++)
    {       
        linesOfContent.Add(i.ToString() +":"+common.ToString());
    }
    index.Add(linesOfContent);
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

cannot convert from 'string' to 'System.Collections.Generic.IEnumerable<string>

From Dev

Cannot implicitly convert type 'System.Collections.Generic.List' to 'string'

From Dev

cannot convert from 'System.Collections.Generic.IEnumerable<char>' to 'string'

From Dev

Cannot implicitly convert type 'System.Collections.Generic.List<System.Data.DataRow>' to 'System.Collections.Generic.List<string>'

From Dev

Cannot implicitly convert type 'System.Collections.Generic.List<AnonymousType#1>' to 'System.Collections.Generic.List<string>'

From Dev

Cannot convert from 'System.Threading.Tasks.Task' to 'System.Collections.Generic.Dictionary<string,string>'

From Dev

Cannot convert from 'System.Threading.Tasks.Task' to 'System.Collections.Generic.Dictionary<string,string>'

From Dev

Cannot implicitly convert type 'System.Collections.Generic.List<String>' to 'System.Collections.Generic.IEnumerable<turon.Model.Products_Products>

From Dev

Cannot convert type 'System.Collections.Generic.List<string>' to 'System.Web.Mvc.SelectList'

From Dev

Convert from 'string' to 'System.Collections.Generic.IEnumerable<string>

From Dev

Cannot implicitly convert type 'void' to 'System.Collections.Generic.List<string>'

From Dev

JSON Restful service. Could not cast or convert from System.String to System.Collections.Generic.List

From Dev

C#, cannot convert from 'System.Collections.Generic.IEnumerable' to 'string[]'

From Dev

Convert type 'System.Collections.Generic.List<string>' to 'System.Collections.Generic.IList<>'

From Dev

CS0029: Cannot implicitly convert type 'System.Collections.Generic.List<<anonymous type: string DeprtmentName, decimal? TotalSalary>>'

From Dev

How can we get List<String> from System.Collections.Generic.List`1[System.String]?

From Dev

Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<string> to string

From Dev

Cannot deserialize the current JSON object..into type 'System.Collections.Generic.List`1[System.String]'

From Dev

Cannot convert 'System.Collections.Generic.List<long?>' to 'System.Collections.Generic.List<long>

From Dev

Cannot implicitly convert type System.Collections.Generic.List<> to System.Collections.Generic.List<>

From Dev

Cannot convert 'System.Collections.Generic.List<long?>' to 'System.Collections.Generic.List<long>

From Dev

Cannot implicitly convert type 'System.Collections.Generic.List<<anonymous type:>>' to 'System.Collections.Generic.List

From Dev

Convert 'System.Collections.Generic.IEnumerable<string>' to 'string[]

From Dev

Cannot implicitly convert type 'string' to 'System.Collections.Generic.ICollection<WebApplication2.Entry>'

From Dev

Cannot implicitly convert type 'void' to 'System.Collections.Generic.Dictionary<string,bool>

From Dev

SignalR : Could not cast or convert from System.String to System.Collections.Generic.IEnumerable

From Dev

Cannot implicitly convert type 'System.Collections.Generic.List< >' to 'System.Collections.Generic.IList< >'

From Dev

Cannot implicitly convert type 'System.Collections.Generic.List< >' to 'System.Collections.Generic.IList< >'

From Dev

"Cannot convert from bool to system.collections.generic.list<bool>" In what seems to be good code

Related Related

  1. 1

    cannot convert from 'string' to 'System.Collections.Generic.IEnumerable<string>

  2. 2

    Cannot implicitly convert type 'System.Collections.Generic.List' to 'string'

  3. 3

    cannot convert from 'System.Collections.Generic.IEnumerable<char>' to 'string'

  4. 4

    Cannot implicitly convert type 'System.Collections.Generic.List<System.Data.DataRow>' to 'System.Collections.Generic.List<string>'

  5. 5

    Cannot implicitly convert type 'System.Collections.Generic.List<AnonymousType#1>' to 'System.Collections.Generic.List<string>'

  6. 6

    Cannot convert from 'System.Threading.Tasks.Task' to 'System.Collections.Generic.Dictionary<string,string>'

  7. 7

    Cannot convert from 'System.Threading.Tasks.Task' to 'System.Collections.Generic.Dictionary<string,string>'

  8. 8

    Cannot implicitly convert type 'System.Collections.Generic.List<String>' to 'System.Collections.Generic.IEnumerable<turon.Model.Products_Products>

  9. 9

    Cannot convert type 'System.Collections.Generic.List<string>' to 'System.Web.Mvc.SelectList'

  10. 10

    Convert from 'string' to 'System.Collections.Generic.IEnumerable<string>

  11. 11

    Cannot implicitly convert type 'void' to 'System.Collections.Generic.List<string>'

  12. 12

    JSON Restful service. Could not cast or convert from System.String to System.Collections.Generic.List

  13. 13

    C#, cannot convert from 'System.Collections.Generic.IEnumerable' to 'string[]'

  14. 14

    Convert type 'System.Collections.Generic.List<string>' to 'System.Collections.Generic.IList<>'

  15. 15

    CS0029: Cannot implicitly convert type 'System.Collections.Generic.List<<anonymous type: string DeprtmentName, decimal? TotalSalary>>'

  16. 16

    How can we get List<String> from System.Collections.Generic.List`1[System.String]?

  17. 17

    Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<string> to string

  18. 18

    Cannot deserialize the current JSON object..into type 'System.Collections.Generic.List`1[System.String]'

  19. 19

    Cannot convert 'System.Collections.Generic.List<long?>' to 'System.Collections.Generic.List<long>

  20. 20

    Cannot implicitly convert type System.Collections.Generic.List<> to System.Collections.Generic.List<>

  21. 21

    Cannot convert 'System.Collections.Generic.List<long?>' to 'System.Collections.Generic.List<long>

  22. 22

    Cannot implicitly convert type 'System.Collections.Generic.List<<anonymous type:>>' to 'System.Collections.Generic.List

  23. 23

    Convert 'System.Collections.Generic.IEnumerable<string>' to 'string[]

  24. 24

    Cannot implicitly convert type 'string' to 'System.Collections.Generic.ICollection<WebApplication2.Entry>'

  25. 25

    Cannot implicitly convert type 'void' to 'System.Collections.Generic.Dictionary<string,bool>

  26. 26

    SignalR : Could not cast or convert from System.String to System.Collections.Generic.IEnumerable

  27. 27

    Cannot implicitly convert type 'System.Collections.Generic.List< >' to 'System.Collections.Generic.IList< >'

  28. 28

    Cannot implicitly convert type 'System.Collections.Generic.List< >' to 'System.Collections.Generic.IList< >'

  29. 29

    "Cannot convert from bool to system.collections.generic.list<bool>" In what seems to be good code

HotTag

Archive