Abhilash J A

Abhilash J A

  • 533
  • 2.4k
  • 598k

ienumerable string use of unassigned local variable c# using

Jan 28 2016 6:16 AM
Hello sir,

In mvc 4 c# view page:-

@{
IEnumerable<string> ListGroupID;
}


@if (TempData["Message"] != null) {

var listTopline = TempData["Message"] as EMGUI.ViewModel.TopLineToExposure;
var ListGroupIds = listTopline.GroupIds;
ListGroupID = ListGroupIds.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Distinct();
}

Problem: when I am tring to use 'ListGroupID' inside foreach there is error occuring "ienumerable string use of unassigned local variable". How to solve this?

@foreach (var item in ListGroupID)
{

}

Answers (2)