Показаны сообщения с ярлыком CSharp. Показать все сообщения
Показаны сообщения с ярлыком CSharp. Показать все сообщения

четверг, 18 марта 2010 г.

Random in C#

This code is wrong example of using Random class. Each element of the arr will be the same.
And don't trust the Debug mode! Because in Debug mode with breakpoints you will see different values each time.

  1. int[] arr = new int[count];
  2.  
  3. for (int j = 0; j < count; j++)
  4. {
  5.   Random rnd = new Random();
  6.  
  7.   arr[j] = rnd.Next(int.MaxValue);
  8. }
* This source code was highlighted with Source Code Highlighter.

Use this one! good Example below:

  1. int[] arr = new int[count];
  2. Random rnd = new Random();
  3.  
  4. for (int j = 0; j < count; j++)
  5. {
  6.   arr[j] = rnd.Next(int.MaxValue);
  7. }
* This source code was highlighted with Source Code Highlighter.

вторник, 2 марта 2010 г.

Authentification-None for one folder(page) when the project is under FormsAuthentifications

Does anybody know how to share (Authentification None) one folder(page) when the project is under FormsAuthentifications?
I've posted the question on the StackOverflow:
http://stackoverflow.com/questions/2364618/authentification-none-for-one-folderpage-when-the-project-is-under-formsauthent

----
Может кто знает как расшарить одну папку(страницу) посредством authentication mode="None", когда весь проект под authentication mode="Forms"?

Бюсь над проблемой, даже запостил ее на StackOverflow, вдруг повезет и подскажут чего-нибудь:
http://stackoverflow.com/questions/2364618/authentification-none-for-one-folderpage-when-the-project-is-under-formsauthent

пятница, 19 февраля 2010 г.

How to convert Stream to byte array

It's pretty easy!

Code on C#:
  1. int length = Convert.ToInt32(inputStream.Length); // get strem length
  2. byte[] byteArr = new byte[length]; // create a byte array
  3. inputStream.Read(byteArr, 0, length);
  4. inputStream.Close();
* This source code was highlighted with Source Code Highlighter.

Code on VB you can find here: http://snipplr.com/view/2012/stream-to-byte-array/