我所著的代碼,但是,當我嘗試建立,編譯器返回:C#錯誤,成員具有相同名稱的
1>code.cs(16,16,16,44): error CS0542: 'DataGridViewPercentageColumn': member names cannot be the same as their enclosing type
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
using System.Linq;
using System.Xml.Linq;
namespace TestSample
{
internal static class DataGridViewPercentageColumn
{
public class DataGridViewPercentageColumn : DataGridViewColumn
{
public DataGridViewPercentageColumn() : base(new DataGridViewPercentageCell())
{
}
}
public class DataGridViewPercentageCell : DataGridViewTextBoxCell
{
public DataGridViewPercentageCell()
{
this.Style.Format = "0%";
}
}
}
}
我怎樣才能解決這個問題,並且,爲什麼這個錯誤發生?
謝謝
內部類DataGridViewPercentageColumn具有與外部類相同的名稱。 – manji
否... o.O,沒有另一個同名的類 – Alexandre
'內部靜態類DataGridViewPercentageColumn'與'public class DataGridViewPercentageColumn'具有相同的名稱。 – jnovacho