C#, .NET, String class

Can anyone explain me , how it's possible.

 string str = "test";  
 str.Concat<>

I invoke Concat method, but String hasn't Concat Method with non-static keyword.

public static String Concat(object arg0);
public static String Concat(IEnumerable<String> values);
public static String Concat(params String[] values);
public static String Concat(params object[] args);
public static String Concat(String str0, String str1);
public static String Concat(object arg0, object arg1);
public static String Concat(String str0, String str1, String str2);
public static String Concat(object arg0, object arg1, object arg2);
public static String Concat(String str0, String str1, String str2, String str3);
public static String Concat(object arg0, object arg1, object arg2, object arg3);
public static String Concat<T>(IEnumerable<T> values);

this is the all Concat overloaded Methods that String class has.

If it's all static what method I've just called , there aren't any overloaded method for Concat with non-static keyword

Jon Skeet
people
quotationmark

You haven't provided full code, but I suspect you're invoking Enumerable.Concat<char>, a generic extension method provided by System.Linq.Enumerable, extending IEnumerable<T>. This is valid because string implements IEnumerable<char>. For example:

IEnumerable<char> sequence = "abc".Concat("def");
foreach (var element in sequence)
{
   Console.WriteLine(element); // Prints a, then b, then c, then d, then e, then f
}

Note that sequence is not a string.

people

See more on this question at Stackoverflow