Tag Archive for c

Sample C# code new

public void testClipBoardContentsAreChangedWhenQueueIsEmptyContentProvided() {
assertTrue(queue.isClipBoardContentsChanged("New Content"));
}

source

paramref Tag C Sharp XML Documentation Comment

/// text for class TestClass
public class TestClass
{
/// <summary>DoWork is a method in the TestClass class.
/// The <paramref name="Int1"/> parameter takes a number.
/// </summary>
public static void DoWork(int Int1)
{
}

/// text for Main
static void Main()
{
}
}

source

list Tag C Sharp XML Documentation Comment

<list type="bullet" | "number" | "table">
<listheader>
<term>term</term>
<description>description</description>
</listheader>
<item>
<term>term</term>
<description>description</description>
</item>
</list>

source

include Tag C Sharp XML Documentation comment

// compile with: /doc:DocFileName.xml

/// <include file='xml_include_tag.doc' path='MyDocs/MyMembers[@name="test"]/*' />
class Test
{
static void Main()
{
}
}

/// <include file='xml_include_tag.doc' path='MyDocs/MyMembers[@name="test2"]/*' />
class Test2
{
public void Test()
{
}
}

source

exception tag C Sharp XML Documentation

// compile with: /doc:DocFileName.xml

/// comment for class
public class EClass : System.Exception
{
// class definition...
}

/// comment for class
class TestClass
{
/// <exception cref="System.Exception">Thrown when...</exception>
public void DoSomething()
{
try
{
}
catch (EClass)
{
}
}
}

source

example tag XML C Sharp Documentation comment

// compile with: /doc:DocFileName.xml

/// text for class TestClass
public class TestClass
{
/// <summary>
/// The GetZero method.
/// </summary>
/// <example> This sample shows how to call the GetZero method.
/// <code>
/// class TestClass
/// {
///     static int Main()
///     {
///         return GetZero();
///     }
/// }
/// </code>
/// </example>
public static int GetZero()
{
return 0;
}

/// text for Main
static void Main()
{
}
}

source

Playing With Extension Methods

using System;

namespace ExtensionMethodTest
{
static class Program
{

public delegate void MyDelegate();

static void Main(string[] args)
{

5.Times(delegate()
{
Console.WriteLine("Hello World");
});

Console.Read();
}

public static void Times(this int count, MyDelegate del)
{
for (int i = 0; i < count; i++)
{
del();
}
}

}
}

source

Generic Control to Head of Page

HtmlGenericControl si = new HtmlGenericControl();
si.TagName = "script";
si.Attributes.Add("type", "text/javascript");
si.Attributes.Add("language", "JavaScript");
si.Attributes.Add("src", ResolveClientUrl("~/scripts/global.js"));

source

The famous InvSqrt()

float InvSqrt (float x)
{
float xhalf = 0.5F * x;
int i = * (int *) &x;
i = 0x5F3759DF - (i >> 1);
x = * (float *) &i;
x = x * (1.5F - xhalf * x * x);
return x;
}

source

Crazy C++ Code

char *s = "DEHLORW";
char *d = "2133464530";

for(i=0; d[i]; i++)
cout << s[d[i]-'0'];

///////////////////////////

i = 1<<1;
i |= 1;
cout << (i<<2) << ":" << (i>>2) << (i==2);

/////////////

x = 0;
cout << (x==0) << (x=0) << (0);

////////////////////////////

class c{
c(int i=0);
public: int a;
};

c::c(int i): a(i) {}

source