foreach (Pair<Pair<int, int>, Cell> cell in sheet.Cells)
{
dgvCells[cell.Left.Right, cell.Left.Left].Value = cell.Right.Value;
}
I am working on creating a excel file from within .NET, using 开发者_如何学Cthis Excel Library
I am getting the warning mentioned in the title. Any ideas?
Just for future reference, and understanding, the error message:
The non-generic type '' cannot be used with type arguments
is replaced with some class, indicates that within your code you are attempting to make use of a non-generic class in a generic way. More specifically you are using some syntax which is incompatible with that type, in this case the <> generic braces on the type "Pair".
To typically solve the problem
- Identify the types use within the file, specifically its use in a generic way. (This should find them: Ctrl + F > "SomeClass<")
- Ensure that the type is as expected (F12 on the type should take you to its declaration)
If the type is different to the expected type you should make use of a using alias to point to the correct type namespace i.e.
using Pair = Fully.Qualified.Namespace.Of.Pair;
If the type is as expected ensure that it is generic, if not you can either modify it to be generic, if you have permission/access to do so, or you could select/create a different type which is more suitable for your purpose.
- Alternativly you could modify your use of the type to be non-generic
It means that Pair
in the code above is referring to System.Web.UI.Pair
instead of some other "pair" class such as System.Collections.Generic.KeyValuePair
(which is generic).
Depending on which Pair
the above code was meant to instantiate, use something like
using Pair = MyNamespace.Pair;
to resolve the issue (this example assumes you really want to use MyNamespace.Pair
).
Update:
It seems that in your case the exact solution is
using Pair = QiHe.CodeLib.Pair;
Because MSDN provides the Pair definition as:
[SerializableAttribute]
public sealed class Pair
There is not a definition that includes Pair<T1, T2>
. If there is another Pair class, you need to include that namespace in your 'using' clause.
精彩评论