While csc /t:library strconcat.cs
with using System.Collections.Generic;
I get an error
strconcat.cs(9,17): error CS0305: Using the generic type
'System.Collections.Generic.List<T>' requires '1' type arguments
mscorlib.dll: (Location of symbol related to previous error)
The .cs code is taken from here: Using Common Language Runtime.
I checked description on msdn but can't compile till now
using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.IO;
using Microsoft.SqlServer.Server;
[Serializable]
[SqlUserDefinedAggregate(Format.UserDefined, MaxByteSize=8000)]
public struct strconcat : IBinarySerialize{
private List values;
public void Init() {
this.values = new List();
}
public void Accumulate(SqlString value) {
this.values.Add(value.Value);
}
public void Merge(strconcat value) {
this.values.AddRange(value.values.ToArray());
}
public SqlString Terminate() {
return new SqlString(string.Join(", ", this.values.ToArray()));
}
public void Read(BinaryReader r) {
int itemCount = r.ReadInt32();
this.values = new List(itemCount);
for (int i = 0; i <= itemCount - 1; i++) {
this.values.Add(r.ReadString());
}
}
public void Write(BinaryWriter w) {
w.Write(this.values.Count);
foreach (string s in this.values) {
w.Write(s);
}
}
}
I'm running Windows 7 x64 with c:\Windows\Microsoft.NET\Framework\v2.0.50727
as well as c:\Windows\Microsoft.NET\Framework64\v2.0.50727>
How to compile? Sorry, I am just starting with c# - I searched some other questions here on SO and those advices did not make a progress for me (
Error explained in article corresponsding to CS0305 - number of type parameters don't match.
In your case you call new List()
with zero type parameters when one is expected like: new List<string>()
and corresponding field definition private List<string> values;
.
Note: if you for some strange reason want non-generic version the corresponding class named ArrayList
, but generic List<T>
is easier and safer to use.