Foreach loop



Please explain about this issue.


You are asking a very basic question, looks like have not gone through the tutorials, pls go through the tutorials.


@jahnavimedhari Variable which you are using having null value so its getting error


Object reference not set to an instance of an object. exactly what it says, you are trying to use a null object as if it was a properly referenced object. Most of the time, when you try to assign value into object, and if the value is null, then this kind of exception occur. [NullReferenceException] indicates that you are trying to access member fields, or function types, on an object reference that points to null. That means the reference to an Object which is not initialized.