C# 当我认为我已经定义了需要定义的内容时,为什么会出现名称空间错误?

C# 当我认为我已经定义了需要定义的内容时,为什么会出现名称空间错误?,c#,C#,我不知道为什么在我确保声明名称空间时会出现名称空间错误 起初,我将FieldCollectionClass声明为private并将其更改为public,但这并没有更改它,所以我缺少什么 我已经添加了我的代码,但没有关于如何解决问题的建议。基本上编辑了我的原始问题,并添加了更多的原始代码来帮助解决这个问题 代码: using System; using System.Collections.Generic; using System.Linq; using System.Text; using S

我不知道为什么在我确保声明名称空间时会出现名称空间错误

起初,我将FieldCollectionClass声明为private并将其更改为public,但这并没有更改它,所以我缺少什么

我已经添加了我的代码,但没有关于如何解决问题的建议。基本上编辑了我的原始问题,并添加了更多的原始代码来帮助解决这个问题

代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Specialized;
using System.Configuration;
using System.Data;

namespace NewCode
 {
 class CommandLineArguments
  {


    public static void Main(string[] args)
    {
    public class ComparisonLogic
    {
        #region 'Declarations'

        public int _noDifferenceFieldCount = 0;
        public int _recordsNotFoundCount = 0;
        private string _compareFieldsString = string.Empty;
        public FieldCollectionClass _Fields = new FieldCollectionClass();

        // Gets and Sets the values for the profile and the files accessed at the command line
        public int Profile
        {
            get { return Profile; }
            set { Profile = value; }
        }

        // Gets and Sets the values for the profile and the files accessed at the command line
        public int File1
        {
            get { return File1; }
            set { File1 = value; }
        }

        // Gets and Sets the values for the profile and the files accessed at the command line
        public int File2
        {
            get { return File2; }
            set { File2 = value; }
        }

        // Gets and Sets the values for the profile and the files accessed at the command line
        public int Delimiter
        {
            get { return Delimiter; }
            set { Delimiter = value; }
        }

        // Gets and Sets the values for the profile and the files accessed at the command line
        public int CounterDifferencesFields
        {
            get { return _noDifferenceFieldCount; }
            set { _noDifferenceFieldCount = value; }

        }

        // Gets and Sets the values for the profile and the files accessed at the command line
        public int CounterRecordsNotFound
        {
            get { return _recordsNotFoundCount; }
            set { _recordsNotFoundCount = value; }
        }

        public FieldCollectionClass 
        {
            get { return _Fields; }
            set { _Fields = value; }
        }


        public int NumberOfFieldsToCompare
        {
            get
            {
                int recordNum = 0;
                if (this.File1 < this.File2)
                    recordNum = this.File1;
                else
                    recordNum = this.File2;

                return recordNum * this.CompareFields.Count;

            }
        }


        public System.Data.DataSet CompareResults
        {
            get { return _dsResult; }           

        }




        public FieldCollectionClass CompareFields
        {
            get
            {
                if (this.File1.GetCompareFields().Count < this.File2.GetCompareFields().Count)
                    return this.File1.GetCompareFields();
                else
                    return this.File2.GetCompareFields();

            }

        }
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
使用System.Collections.Specialized;
使用系统配置;
使用系统数据;
名称空间新代码
{
类CommandLineArguments
{
公共静态void Main(字符串[]args)
{
公共类比较逻辑
{
#区域“声明”
公共int_noDifferenceFieldCount=0;
public int_recordsNotFoundCount=0;
私有字符串_compareFieldsString=string.Empty;
public FieldCollectionClass_Fields=new FieldCollectionClass();
//获取并设置配置文件和在命令行访问的文件的值
公共int配置文件
{
获取{返回配置文件;}
设置{Profile=value;}
}
//获取并设置配置文件和在命令行访问的文件的值
公共int文件1
{
获取{返回文件1;}
设置{File1=value;}
}
//获取并设置配置文件和在命令行访问的文件的值
公共int文件2
{
获取{返回文件2;}
设置{File2=value;}
}
//获取并设置配置文件和在命令行访问的文件的值
公共整型定界符
{
获取{返回分隔符;}
设置{分隔符=值;}
}
//获取并设置配置文件和在命令行访问的文件的值
公共int反差分字段
{
获取{return\u noDifferenceFieldCount;}
设置{u noDifferenceFieldCount=value;}
}
//获取并设置配置文件和在命令行访问的文件的值
公共int计数器记录查找
{
获取{return\u recordsNotFoundCount;}
设置{u recordsNotFoundCount=value;}
}
公共字段集合类
{
获取{return\u Fields;}
设置{u Fields=value;}
}
公共int NumberOfFieldsToCompare
{
得到
{
int-recordNum=0;
if(this.File1
错误:
命名空间名称“FieldCollectionClass”找不到

您是否在文件顶部的某个位置有使用FieldCollectionClass的
文件?如果有,则不应该。看起来
FieldCollectionClass
是一个类,而不是命名空间。但您还没有显示该类的定义位置,因此这只是一个猜测。@itsme86没有这些不是我的using语句吗:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Collections.Specialized;using System.Configuration;using System.Data;除非其中一个链接到它?我确实从另一个文件复制了一些代码,这可能是原因吗?我从中获取这段代码的文件没有FieldCollectionClass作为命名空间。我尝试更改collectionofFields,但没有任何更改。@Rory FieldCollectionClass的命名空间是什么?将它作为using语句添加到文件顶部。@Fraser命名空间是CompareFileUtility。我按你说的做了,但是出于某种原因,它仍然不喜欢它。@Rory FieldCollectionClass上的访问修饰符是什么?您的文件顶部有
using FieldCollectionClass
吗?如果有,您不应该。看起来
FieldCollectionClass
是一个类,而不是一个名称空间。您还没有显示该类的定义位置,是吗o这真的只是一个猜测。@itsme86不,我不知道这些是我的using语句:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Collections.Specialized;using System.Configuration;using System.Data;除非其中一个与之相链接?我确实复制了一些代码这可能是另一个文件的原因吗?虽然我从中获取这段代码的文件没有FieldCollectionClass作为命名空间。我尝试更改collectionofFields,但没有任何更改。@Rory FieldCollectionClass的命名空间是什么?将其作为using语句添加到文件顶部。@Fraser命名空间是可比较的Sutibility.Classes我按照你说的做了,但出于某种原因,它仍然不喜欢它。@Rory FieldCollectionClass上的访问修饰符是什么?