PDA

View Full Version : Programming Question



Dwood
February 28th, 2015, 02:25 PM
When I see SomeText<T> in a programming file, what am I looking at? What's it called when a programmer does that? I'm looking for more info but I don't see any data on it from any of my Googling.

Edit:



public static TResult SafeInvoke<T, TResult>(this T isi, Func<T, TResult> call) where T : ISynchronizeInvoke
{
if (isi.InvokeRequired) {
IAsyncResult result = isi.BeginInvoke(call, new object[] { isi });
object endResult = isi.EndInvoke(result); return (TResult)endResult;
}
else
return call(isi);
}


For example, in the above C# code, what's going on? Or rather, what terms describe this?

RadWolfie
February 28th, 2015, 03:48 PM
In C++ it's called template. However your code example is in C#, it seems to be named as generics. Found it from this link (https://msdn.microsoft.com/en-us/library/c6cyy67b.aspx). I have used templates often in my project, sometimes for multi-thread safe class/variables whenever I need it across another thread to be used. Hope this is helpful for quick look up myself, plus Std library, for good example "std vector", also used this too.

P.S. In native C language, it is not supportive.

Dwood
March 2nd, 2015, 10:41 AM
Thanks!

RadWolfie
March 2nd, 2015, 12:09 PM
Np

luckylike95
April 4th, 2015, 08:57 AM
In native C, it is not supportive.