4
Inconsistent accessibility: field type 'DannyGeneral.OptionsFile' is less accessible than field 'AnimationEditor.Form1.setting_file'

在Form1中我做了:

public  OptionsFile setting_file;

错误在 setting_file 部分。

这是 Options_File 代码的开头:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Configuration;




namespace DannyGeneral
{
    class OptionsFile
    {

        string path_exe;
        string temp_settings_file;
        string temp_settings_dir;
        string Options_File;
        StreamWriter sw;
        StreamReader sr;


    public OptionsFile(string settings)
    {
        if (!File.Exists(settings))
        {
            if (!Directory.Exists(Path.GetDirectoryName(settings)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(settings));
            }
            File.Create(settings).Close();
        }
        path_exe = Path.GetDirectoryName(Application.LocalUserAppDataPath);
        Options_File = settings; 
    }

在 Form1 的顶部:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using DannyGeneral;
using unfreez_wrapper;

namespace AnimationEditor
{
    public partial class Form1 : Form
    {
        private static string settings_dir;
        private static string settings_file;
        public  OptionsFile setting_file;
4

3 回答 3

9

OptionsFile如果要将类型用作public属性,则需要将类型本身设为公开。

使用辅助功能级别的限制(C# 参考)

于 2012-07-05T21:04:04.953 回答
2

将类标记OptionsFilepublic或将字段标记setting_File为非公共(internalprivate)。

于 2012-07-05T22:04:13.170 回答
0

我有同样的问题,但我现在明白了,那些不明白的人应该是

   namespace DannyGeneral
{
    public class OptionsFile
    {

        string path_exe;
        string temp_settings_file;
        string temp_settings_dir;
        string Options_File;
        StreamWriter sw;
        StreamReader sr;
于 2016-02-18T21:03:58.273 回答