2
Answers

ienumerable string use of unassigned local variable c# using

Ask a question
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)