TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Prashant Jadhav
NA
38
13.7k
error while assigning object of type to element of reference
Aug 1 2014 6:27 AM
hi guys i was trying to create an class which contain array of reference type
and i was trying to assign same type object to the array element but it was showng me some errors i dont know where i am doing wrong that code is as follow please check it out and tell me where i did wrong
using System;
namespace EnumExpl
{
class employee
{
public string firstname;
public string lastname;
}
class employees
{
employee prashant=new employee()
{
firstname="prashant",
lastname="jadhav"
};
employee prakash=new employee()
{
firstname="prakash",
lastname="jadhav"
};
public employee[] Empl = new employee[2];
Empl[0]=prashant;
}
class Program
{
static void Main(string[] args)
{
}
}
}
Error1Array size cannot be specified in a variable declaration (try initializing with a 'new' expression)c:\users\prashant\documents\visual studio 2010\Projects\enumarator\enumarator\Program.cs2714enumarator
Error2Invalid token '=' in class, struct, or interface member declarationc:\users\prashant\documents\visual studio 2010\Projects\enumarator\enumarator\Program.cs2716enumarator
Error3Invalid token ';' in class, struct, or interface member declarationc:\users\prashant\documents\visual studio 2010\Projects\enumarator\enumarator\Program.cs2725enumarator
these are those error messege i was getting
Reply
Answers (
9
)
how to restrict a gridview for not taking more than 5 recor
Copy the Contents from one file to another file line by line