Click here to Skip to main content
15,916,378 members
Home / Discussions / C#
   

C#

 
Generallog file parser in c# Pin
balsmn27-Oct-04 2:05
balsmn27-Oct-04 2:05 
GeneralRe: log file parser in c# Pin
sreejith ss nair27-Oct-04 2:52
sreejith ss nair27-Oct-04 2:52 
GeneralRe: log file parser in c# Pin
balsmn28-Oct-04 2:39
balsmn28-Oct-04 2:39 
GeneralRe: log file parser in c# Pin
sreejith ss nair28-Oct-04 2:48
sreejith ss nair28-Oct-04 2:48 
Generalanother for you^_* Pin
momer27-Oct-04 2:01
momer27-Oct-04 2:01 
GeneralRe: another for you^_* Pin
sreejith ss nair27-Oct-04 3:00
sreejith ss nair27-Oct-04 3:00 
QuestionHow to do this in C#? Pin
momer27-Oct-04 1:44
momer27-Oct-04 1:44 
AnswerRe: How to do this in C#? Pin
sreejith ss nair27-Oct-04 2:35
sreejith ss nair27-Oct-04 2:35 
CLR won't execute the code which is unsafe. Here your requirement is to execute this unsafe code.
For executing unsafe code in managed environment you have to use unsafe keyword.
Eg:

<br />
<br />
using System;<br />
<br />
namespace ConsoleApplication1<br />
{<br />
	/// <summary><br />
	/// Summary description for Class1.<br />
	/// </summary><br />
	class Class1<br />
	{<br />
		public static unsafe void CopyMethod(byte[] src,int cntsrc,byte[] dnc,int cntdnc,int count)<br />
		{<br />
			if(src==null||cntdnc<0||dnc==null||cntdnc<0||count<0)<br />
				throw new ArgumentException();<br />
			int srclen=src.Length;<br />
			int dnclen=dnc.Length;<br />
			if(srclen-cntsrc<count||dnclen-cntdnc<count)<br />
				throw new ArgumentException();<br />
			// The following fixed statement pins the location of<br />
			// the src and dst objects in memory so that they will<br />
			// not be moved by garbage collection.<br />
			fixed(byte* pSrc=src, pDnc=dnc)<br />
			{<br />
				byte* pscr=pSrc,pdnc=pDnc;<br />
				// Loop over the count in blocks of 4 bytes, copying an<br />
				// integer (4 bytes) at a time:<br />
				for (int n = count >> 2; n != 0; n--)<br />
				{<br />
					*((int*)pdnc) = *((int*)pscr);<br />
					pdnc += 4;<br />
					pscr += 4;<br />
				}<br />
				// Complete the copy by moving any bytes that weren't<br />
				// moved in blocks of 4:<br />
				for (count &= 3; count != 0; count--)<br />
				{<br />
					*pdnc = *pscr;<br />
					pdnc++;<br />
					pscr++;<br />
				}<br />
			}<br />
		}<br />
<br />
		static void Main(string[] args) <br />
		{<br />
			byte[] a = new byte[100];<br />
			byte[] b = new byte[100];<br />
			for(int i=0; i<100; ++i) <br />
				a[i] = (byte)i;<br />
			CopyMethod(a, 0, b, 0, 100);<br />
			Console.WriteLine("The first 10 elements are:");<br />
			for(int i=0; i<10; ++i) <br />
				Console.Write(b[i] + "{0}", i < 9 ? " " : "");<br />
			Console.WriteLine("\n");<br />
		}<br />
	}<br />
}<br />


The above example uses pointers to copy an array of bytes from src to dst.Big Grin | :-D

Sreejith Nair
[ My Articles ]
GeneralRe: How to do this in C#? Pin
momer27-Oct-04 2:52
momer27-Oct-04 2:52 
Generalaccessing email account settings of outlook through c# Pin
chintancs27-Oct-04 1:32
chintancs27-Oct-04 1:32 
GeneralRe: accessing email account settings of outlook through c# Pin
sreejith ss nair27-Oct-04 4:02
sreejith ss nair27-Oct-04 4:02 
GeneralRe: accessing email account settings of outlook through c# Pin
chintancs28-Oct-04 0:15
chintancs28-Oct-04 0:15 
GeneralConverting ulong into an array of booleans Pin
NiteShade27-Oct-04 1:13
NiteShade27-Oct-04 1:13 
GeneralRe: Converting ulong into an array of booleans Pin
Mike Dimmick27-Oct-04 1:58
Mike Dimmick27-Oct-04 1:58 
GeneralAdd icons in chat windows Pin
verma-rahul27-Oct-04 0:54
verma-rahul27-Oct-04 0:54 
GeneralDocked Controls wont use (e.g. draw on) new area after resize Pin
Sebastian Schneider27-Oct-04 0:47
Sebastian Schneider27-Oct-04 0:47 
GeneralRe: Docked Controls wont use (e.g. draw on) new area after resize Pin
Anonymous27-Oct-04 2:26
Anonymous27-Oct-04 2:26 
GeneralRe: Docked Controls wont use (e.g. draw on) new area after resize Pin
sreejith ss nair27-Oct-04 2:28
sreejith ss nair27-Oct-04 2:28 
GeneralRe: Docked Controls wont use (e.g. draw on) new area after resize Pin
Sebastian Schneider27-Oct-04 3:39
Sebastian Schneider27-Oct-04 3:39 
GeneralRe: textbox with auto &quot;scrolling&quot; Pin
Member 146896026-Oct-04 23:44
Member 146896026-Oct-04 23:44 
GeneralRe: textbox with auto &quot;scrolling&quot; Pin
Member 146896026-Oct-04 23:53
Member 146896026-Oct-04 23:53 
GeneralRe: textbox with auto &quot;scrolling&quot; Pin
Stefan Troschuetz26-Oct-04 23:57
Stefan Troschuetz26-Oct-04 23:57 
GeneralRe: textbox with auto &quot;scrolling&quot; Pin
Stefan Troschuetz26-Oct-04 23:53
Stefan Troschuetz26-Oct-04 23:53 
GeneralRe: textbox with auto &quot;scrolling&quot; Pin
Dave Kreskowiak27-Oct-04 3:36
mveDave Kreskowiak27-Oct-04 3:36 
GeneralC++ to C# help quick please Pin
hagay_ar26-Oct-04 23:21
hagay_ar26-Oct-04 23:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.