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
k
NA
25
0
error when I declare it as a "public".
Oct 21 2008 2:13 AM
I try to to serialize Dictionary object to xml file. That why I have to declare like this
public Dictionary dict
for object dict.
But If I declare "public" for object dict there was a error occur:
error CS0052: Inconsistent accessibility: field type 'HashTableDictionary.Dictionary' is less accessible than field 'HashTableDictionary.Form1.dict'
It I declare "private" for object dict. It's was ok, but my serialize function do not work.
Anyone can help me to solve error CS0052 and explain it for me?? thanks in advance!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HashTableDictionary
{
class Node
{
public string word;
public string mean;
public Node next;
...
}
class LinkList : Node
{
public Node[] hashtable = new Node[26];
...
}
class Dictionary : LinkList
{
public Dictionary() { }
...
}
}
//in another file:
namespace HashTableDictionary
{
public partial class Form1 : Form
{
public string[] buffer = new string[200];
public int i;
public Dictionary dict = new Dictionary(); //error here!
...
}
private void Save_btn_Click(object sender, EventArgs e)
{
XmlSerializer s = new XmlSerializer(typeof(Dictionary));
TextWriter tr = new StreamWriter("DictXml.xml");
s.Serialize(tr,dict);
tr.Close();
}
}
Reply
Answers (
1
)
Progress bar
Compile using windows vista and c# 2008 express