Servefault.com - Stories tagged with C#
1
votes

Race Condition & Synchronization in C# - Coding N Design

posted by sankarsansankarsan 11 days, 21 hours, 33 minutes ago
Sunday, July 18, 2010 12:52:05 PM GMT
We have heard about the term race condition in relation to threads.This is basically a scenario where two or more threads are competing(racing) to read/write from a shared memory location leading to the possibilities of leaving the program in an inconsistent state. Consider the program shown below: public class A { public int x = 0; public int y = 0... (more)
category: Unspecified | clicked: 0 | comment | | source: codingndesign.com
tags: C#, Monitor, Threading
1
votes

Generate Random strong password string using C#

posted by learndotnetlearndotnet 31 days, 23 hours, 43 minutes ago
Monday, June 28, 2010 10:41:21 AM GMT
Here is a very useful C# code snippet for generating random strong passwords. The password is generated using upper case and lower case alphabets, numerals and special characters. //create constant strings for each type of charactersstatic string alphaCaps = "QWERTYUIOPASDFGHJKLZXCVBNM";static string alphaLow = "qwertyuiopasdfghjklzxcvbnm";static string numerics = "1234567890";static string special = "@#$";//create another string which is a concatenation of all abovestring allChars = alphaCaps + alphaLo... (more)
category: ASP.NET | clicked: 0 | comment | | source: advanceddotnettutorial.blogspot.com
tags: C#, Generate, random, string, strong password
1
votes

Single Assignment & readonly Fields in C# - Coding N Design

posted by sankarsansankarsan 32 days, 17 hours ago
Sunday, June 27, 2010 5:24:44 PM GMT
We have all heard about immutable objects, the objects whose field values cannot be altered throughout it’s lifetime.Immutable objects are simpler to deal with in case concurrent programs where they can be shared between multiple threads.The single assignment variables variables which is once assigned a value cannot be reassigned again.These are inherently immut... (more)
category: Unspecified | clicked: 0 | comment | | source: codingndesign.com
tags: C#
2
votes

Programmer's Blog: Highlight GridView Row On MouseOver Using Javascript in Asp.net

posted by gsanthoshbegsanthoshbe 125 days, 22 hours, 26 minutes ago
Friday, March 26, 2010 11:58:33 AM GMT
Asp.net GridView gives us huge facility that we can't imagine few years ago. But still we have a lot of chance to improve look & feel as well as GridView functionality. Here in this article i will describe how you can highlight a gridview row when move the mouse over the row and also how to retain the original background color when user leaves the mouse from a row or in mouseout event. After googling i found a lot of series on Gridview row highlighting issues but unfortunately most of them uses style... (more)
category: ASP.NET | clicked: 2 | comment | | source: visualcppsupport.blogspot.com
tags: C#
2
votes

Programmer's Blog: Merge GridView Cells Or Columns in Row ASP.NET

posted by gsanthoshbegsanthoshbe 125 days, 22 hours, 28 minutes ago
Friday, March 26, 2010 11:56:57 AM GMT
In most of the cases specially for reporting purpose we need to merge GridView cells or columns for client preferred output. In this example i will show you how one can merge GridView cells or columns in asp.net C#. My special focus is on to merge cells when both contains same or equal data. So that the GridView looks like a traditional report. For merging GridView cells here i want to show you a generic way so that you can use only one common method for all GridViews in your project where applicable. Le... (more)
category: ASP.NET | clicked: 0 | comment | | source: visualcppsupport.blogspot.com
tags: C#
2
votes

Programmer's Blog: How to track visitors to your site in ASP.NET & C#

posted by gsanthoshbegsanthoshbe 125 days, 22 hours, 29 minutes ago
Friday, March 26, 2010 11:55:26 AM GMT
Once you have published a site in ASP.NET, you'd like to know who are your visitors. One way is to check your event log on the host server. Another option is to write your own code. You'd basically like to log the IP address, and DNS name for the visitor, and it would be nice to know which page they are visiting. To log the ip address using ASP.NET, you can call: Request.ServerVariables["HTTPXFORWARDED_FOR"] Another usefull variable is Request.ServerVariables["REMOTE_ADDR"] A combination of the ... (more)
category: ASP.NET | clicked: 0 | comment | | source: visualcppsupport.blogspot.com
tags: C#
2
votes

Programmer's Blog: Send Email With Attachment in asp.net

posted by gsanthoshbegsanthoshbe 125 days, 22 hours, 34 minutes ago
Friday, March 26, 2010 11:51:01 AM GMT
In this example i am going to describe how to send email with attachment in ASP.NET using fileUpload Control. I am saving the uploaded file into memory stream rather then saving it on server.And for this example i m using Gmail SMTP server to send mail, this code also works fine with any SMTP Server. For sending Email in ASP.NET , first of allwe need to add Syatem.Net.Mail namespace in code behind of aspx page. C# Code Behind using System; using System.Data; using System.Configuration; using Sy... (more)
category: ASP.NET | clicked: 0 | comment | | source: visualcppsupport.blogspot.com
tags: C#
4
votes

Programmer's Blog: C# how to open a file that is locked by another process

published 120 days, 1 hour, 38 minutes ago posted by gsanthoshbegsanthoshbe 125 days, 22 hours, 39 minutes ago
Thursday, April 01, 2010 8:46:49 AM GMT Friday, March 26, 2010 11:45:58 AM GMT
If the file is locked by the process exclusively, it is not possible to open those files. But if the process holds only shared lock, we can open the file using c# using the following code, FileStream objf = new FileStream(”Ouput.xls”, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); Excel hold the shared lock on the files. The Following is an example program to read a file, using System.IO; public static byte[] ReadFile(string filePath){byte[] buffer;FileStream fileStream = newFileStream(... (more)
category: ASP.NET | clicked: 0 | comment | | source: visualcppsupport.blogspot.com
tags: C#
5
votes

Programmer's Blog: C# : Redraw a Whole Control on Resize

published 120 days, 1 hour, 38 minutes ago posted by gsanthoshbegsanthoshbe 125 days, 22 hours, 40 minutes ago
Thursday, April 01, 2010 8:46:49 AM GMT Friday, March 26, 2010 11:44:28 AM GMT
When custom controls or Windows Forms controls likePanelare resized, only their newly exposed portions are redrawn. However, this behaviour sometimes does not provide the desired results (see fig. 1 below). This example shows how to ensureredrawing of the whole control after resizingResi zeRedraw property. Fig. 1. A partially redrawn control after resizing. Redrawing the whole control on resize TheResizeRedrawprotec... (more)
category: ASP.NET | clicked: 0 | comment | | source: visualcppsupport.blogspot.com
tags: C#
5
votes

Programmer's Blog: Implementing the Repository Pattern in C# ASP .NET

published 120 days, 1 hour, 38 minutes ago posted by gsanthoshbegsanthoshbe 125 days, 22 hours, 42 minutes ago
Thursday, April 01, 2010 8:46:49 AM GMT Friday, March 26, 2010 11:42:54 AM GMT
Introduction Writing a C# ASP .NET web application which utilizes a database can create increasingly complex code. The more complex code gets, the more difficult it becomes to debug, maintain, and enhance. The Repository design pattern is a way of introducing architecture into your C# ASP .NET web application, which creates a clear layer of separation between your web forms and database accessible layers. The Repository pattern helps organize a web application to form a 3-tier architecture and provide... (more)
category: ASP.NET | clicked: 22 | comment | | source: visualcppsupport.blogspot.com
tags: ASP.NET, C#
4
votes

Programmer's Blog: C# yield operator

published 120 days, 1 hour, 38 minutes ago posted by gsanthoshbegsanthoshbe 125 days, 22 hours, 44 minutes ago
Thursday, April 01, 2010 8:46:49 AM GMT Friday, March 26, 2010 11:40:51 AM GMT
Prior to .NET 2.0, the only way you could create your own collection which could be traversed using the 'foreach' construct was by having you class implementing the IEnumerable and IEnumerator Interfaces. However since .NET 2.0 we have a new operator called 'yield'. This allows your class to be iterated by its consumer but without the need to implement the above-mentioned interfaces. Let us see a small example of how this works: // Our class does not implement any interface ! public class Sch... (more)
category: ASP.NET | clicked: 0 | comment | | source: visualcppsupport.blogspot.com
tags: C#
5
votes

Programmer's Blog: Const vs. readonly vs. static readonly in C# .NET

published 120 days, 1 hour, 38 minutes ago posted by gsanthoshbegsanthoshbe 125 days, 22 hours, 46 minutes ago
Thursday, April 01, 2010 8:46:49 AM GMT Friday, March 26, 2010 11:38:41 AM GMT
Here are the differences between C# .NETconst,readonlyandstatic readonlyfields. Constants:Static by defaultMust have compilation-time value (i.e.: you can have "A"+"B" but cannot have method calls)Can be used in attributesAre copied into every assembly that uses them (every assembly gets a local copy of values)Could be declared within functionsThe compiler performs some optimization by not declaring any stack space for the field Readonly instance fields:Are evaluated when instance is createdMust have s... (more)
category: ASP.NET | clicked: 3 | comment | | source: visualcppsupport.blogspot.com
tags: C#
4
votes

Programmer's Blog: Scanning running processes in C#

published 120 days, 1 hour, 38 minutes ago posted by gsanthoshbegsanthoshbe 125 days, 22 hours, 48 minutes ago
Thursday, April 01, 2010 8:46:49 AM GMT Friday, March 26, 2010 11:36:47 AM GMT
Using System.Diagnostics we can know the processes currently running in our machine. The code is quite simple. In the following demo, we will show all the processes running on your machine, plus a check if you are running Windows Live Messenger (a.k.a. MSN Messenger). using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; namespace CheckRunningProcesses { class Program { static void Main(string[] args) { const string messenger = ... (more)
category: ASP.NET | clicked: 0 | comment | | source: visualcppsupport.blogspot.com
tags: C#
5
votes

Programmer's Blog: Passing Values between Windows forms in C#.net

published 120 days, 1 hour, 38 minutes ago posted by gsanthoshbegsanthoshbe 125 days, 22 hours, 50 minutes ago
Thursday, April 01, 2010 8:46:49 AM GMT Friday, March 26, 2010 11:35:02 AM GMT
If you are working on a windows application, you may have have come accross a situation where you have to pass avariable between two forms. Although there are many ways to do it, Sticking to my blog’s style, I will post the most easiest way to do it, Steps to pass variables between formsLets assume that the Form that is passing the variable as Form1 and the one recieving them as Form2Now Declare a public variable at the top of the form2 Class, so that it is global variable.Lets assume that variable to ... (more)
category: ASP.NET | clicked: 0 | comment | | source: visualcppsupport.blogspot.com
tags: C#
5
votes

C# code to extract Email

published 120 days, 1 hour, 38 minutes ago posted by gsanthoshbegsanthoshbe 125 days, 22 hours, 53 minutes ago
Thursday, April 01, 2010 8:46:49 AM GMT Friday, March 26, 2010 11:31:54 AM GMT
The Following is a sample code to Extract Email addresses from a given string and store them into an array.I will give the code as Method, so that you can easily import it into your application.This code can be easily used to extract Email Id’s from a web page, just pass the HTML of the web page as the Text2Scrape. This Class uses String arrays to store results (more)
category: ASP.NET | clicked: 0 | comment | | source: visualcppsupport.blogspot.com
tags: C#
4
votes

Programmer's Blog: C# class to check for internet Connection

published 120 days, 1 hour, 38 minutes ago posted by gsanthoshbegsanthoshbe 125 days, 22 hours, 54 minutes ago
Thursday, April 01, 2010 8:46:49 AM GMT Friday, March 26, 2010 11:30:20 AM GMT
I found this piece of code on the internet, the author of this code isTamer Oz. using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace Coderbuddy { public class CheckInternetConnection { [DllImport("wininet.dll")] private extern static bool InternetGetConnectedState(out int Description, int ReservedValue); public bool IsInternetConnectionAvailable() { int Desc; return InternetGetConnectedState(out Desc, 0); } } } (more)
category: ASP.NET | clicked: 0 | comment | | source: visualcppsupport.blogspot.com
tags: C#
5
votes

Writing object to object mapper: my mapper vs AutoMapper - Gunnar Peipman's ASP.NET blog

published 159 days, 7 hours, 7 minutes ago posted by gpeipmangpeipman 168 days, 3 hours, 57 minutes ago
Sunday, February 21, 2010 3:17:13 AM GMT Friday, February 12, 2010 6:27:16 AM GMT
As my object to object mapper is now almost completed and I am sure it is good idea to stay on LCG (Lightweight Code Generation) I can now compare the performance of my mapper to AutoMapper. (more)
category: Visual Studio | clicked: 0 | comment | | source: weblogs.asp.net
tags: .Net, C#, object to object mapping, performance
4
votes

Writing object to object mapper: first implementations

published 166 days, 16 hours, 45 minutes ago posted by gpeipmangpeipman 172 days, 21 hours, 56 minutes ago
Saturday, February 13, 2010 5:39:53 PM GMT Sunday, February 07, 2010 12:29:02 PM GMT
I wrote some object to object mapping code and introduced it in some of my previous postings about performance. As I received 22x performance raise when trying out different mapping methods it is now time to make my code nice. In this posting I will show you how I organized my code to classes. Yes, you can use my classes in your work if you like. (more)
category: ASP.NET | clicked: 0 | comment | | source: weblogs.asp.net
tags: .Net, C#, object to object mapping, performance
2
votes

Performance: Using LCG to copy property values of two objects

published 166 days, 16 hours, 45 minutes ago posted by gpeipmangpeipman 174 days, 16 hours, 2 minutes ago
Saturday, February 13, 2010 5:39:53 PM GMT Friday, February 05, 2010 6:22:23 PM GMT
Today I gave last performance boost to my property values copying mechanism. I would like to thank my readers Ron and David to remind me Lightweight Code Generation (LCG) and pointing me out aussie bloke blog entry Generic copy object using Lightweight Code Generation. In this posting I will show you last performance boost and put down a summary about my experiment this far. (more)
category: Visual Studio | clicked: 1 | comment | | source: weblogs.asp.net
tags: .Net, C#, lcg, performance
6
votes

Configuring MEF with Linq To Xml Part 2: Making MEF recomposition on the fly when the file is edited - Alex van Beek - blog community

published 180 days, 20 hours, 47 minutes ago posted by alexbalexb 189 days, 23 hours, 11 minutes ago
Saturday, January 30, 2010 1:37:12 PM GMT Thursday, January 21, 2010 11:13:24 AM GMT
In this post I’m going to show how you can make use of MEF’s recomposition features to recomposition on the fly when the content of the configuration XML file in which the exports are defined, is changed. (more)
category: Silverlight | clicked: 1 | comment | | source: blogs.infosupport.com
tags: .Net 4.0, C#, ExportProvider, FileSystemWatcher, Linq To XML, MEF, Silverlight 4
Previous 1 2 Next