{Log in or Register}

This Is For Coders and Programmers. Code Anywhere!!!

July 20th, 2009 1 Comment   Posted in AJAX, ASP.NET, C#, Community, PHP, Programming, SEO

Hello Guys,

Check www.meetcoder.com…. and Code Anywhere!!!    This is For Coders and Programmers.  SignUp for UpDates.www.meetcoder.com

Enums in C# - use sbyte

August 14th, 2008 No Comments   Posted in C#

C# Code Specification:

The following example declares an enum type named Alignment with an underlying type of sbyte.

enum Alignment: sbyte
{
Left = -1,
Center = 0,
Right = 1
}

When you use enumerations in C# - you easy can declare new values as sbyte. Standart type of variable is int, but you can use and sbyte type.

C# - start only one copy of the program

August 10th, 2008 No Comments   Posted in C#

If you need that the program was started an only to one copy - can take advantage of such simple and useful class:

public class SingleInstance
{
private bool firstInstance = false;

public bool FirstInstance
{
get { return firstInstance; }
}

public SingleInstance()
{
Mutex mutex=null;
try
{
mutex = Mutex.OpenExisting("ProgramName");
}
catch (WaitHandleCannotBeOpenedException e)
{
firstInstance = true;
}

if (mutex == null)
{
mutex = new Mutex(false, "ProgramName");

GC.KeepAlive(mutex);
}
}
}

Now, we need edit Program.cs like here:

[STAThread]
static void Main()
{
SingleInstance single = new SingleInstance();

if (single.FirstInstance)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}

Now the program will be started only in one copy. A code works on the different versions of Windows - including Vista.


Tags: , ,

How to do redirect by web.config in ASP.NET

July 29th, 2008 No Comments   Posted in ASP.NET

If you want create the mod_rewrite analogue and use links as mysite/user/DeVoid or send an user on other page - use web.config option urlMappings in ASP.NET:

<configuration>
<system.web>
<urlMappings enabled="true">
<add
url="~/Article28.aspx"
mappedUrl="~/MyNewBestArtile.aspx"/
>
<urlMappings>
</system.web>
</configuration>

Using urlMappings you will be able to do your site on ASP.NET more attractive for an user

Welcome to Community!

July 19th, 2008 No Comments   Posted in Community

I created this site for programmers, my colleagues, could publish here the ideas, divided experience, to communicate between itself, help novices. Every visitor which will be registered - can write in blog, leave a comment, see the users profiles. I hope you will find here much interesting.