Here are some usefull Options to tick in the C# 2010 Options Dialog Box
To Show the Configuration and Platform options in the Project property Debug Window
Projects and Solutions - General - Show Advance build configurations
To redirect output to the immediate window
Debbugging - General - Redirect all output window text to the Immediage window
How to change the Exception Handling Options
Tools - Customize - Commands
Menu bar: Debug
Click where you want to put the new Command, in the controls dialog box
Add Command, Debug, Exceptions...
Ok, Close
Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts
Tuesday, July 24, 2012
Friday, May 25, 2012
C# Emumeration with custom ToString method
When using Enum in any language you want to have a method to pretty print them. A very easy way to accomplish this in C# is with extension methods.
Here is a quick example
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace RickysGuitars { public enum GuitarType { ACOUSTIC, ELECTRIC } public static class GuitarTypeExtentions { public static string ToPrettyString(this GuitarType source) { switch (source) { case GuitarType.ACOUSTIC: return "Acoustic Guitar"; case GuitarType.ELECTRIC: return "Electric Guitar"; } return null; } } }
An example of the method call would be
GuitarType a = GuitarType.ELECTRIC;
Debug.WriteLine(a.ToPrettyString());
which prints: Electric Guitar
Thursday, November 10, 2011
Formatting code for HTML display
Hi,
This is really a great link
http://www.manoli.net/csharpformat/
to format c# or VB.NET/VBA/VB code in HTML 4 format to display on the web
This is really a great link
http://www.manoli.net/csharpformat/
to format c# or VB.NET/VBA/VB code in HTML 4 format to display on the web
Monday, November 15, 2010
How to send a mail message in C#
Here you can find a piece of code to send mail using c#.
Please not that you need to know your Smtp Host server name to be able to sent out any mail.
In addtion I added a couple of lines to get the current user name.
You can map the current user name to an email address so that you can send the mail out from the current user mail address
ex: mailAddress = abeti then use mrblue.abeti@companyname.com as mail address
Please not that you need to know your Smtp Host server name to be able to sent out any mail.
In addtion I added a couple of lines to get the current user name.
You can map the current user name to an email address so that you can send the mail out from the current user mail address
ex: mailAddress = abeti then use mrblue.abeti@companyname.com as mail address
using System.Net.Mail; using System.Security.Principal; private void button1_Click(object sender, EventArgs e) { string mailAddress; mailAddress = WindowsIdentity.GetCurrent().Name; Console.Write(mailAddress); MailMessage message = new MailMessage(); message.From = new MailAddress("mrblue.abeti@companyname.com"); message.To.Add(new MailAddress("mrred.pini@companyname.com")); message.CC.Add(new MailAddress("mryellow.ciliegi@companyname.com")); message.Subject = "Message From .Net"; message.Body = "This is the content"; string pdfPath = "C:\\test\\"; string pdfFileName = "prova.pdf"; Attachment pdfFile = new Attachment(pdfPath + pdfFileName); SmtpClient client = new SmtpClient(); client.Host="MAILSERVER"; //client.Send(message); }
Thursday, September 9, 2010
C# COM Exposed Collection
Code can be found here and here
Visual Studio 2008 and Excel 2003-2008 required
Further details con be found on this post
Hi,
You can find attache a project that contains code that will allow you to create a C# COM exposed collection so that
1) It has Item as default property. So from VB 6.0 you can just do employees(1).Name
2) It is a IEnumerable object
3) It has a GetEnumerator() function that can be used to create VB 6.0 strongly typed collection that can be iterated using the For Each loop
Public Function NewEnum() As IUnknown
Set NewEnum = mNetList.GetEnumerator
End Function
Please do not to register the CLASS for COM interop just go to Project/Properties/Build Register for COM Interop.
Do not use the option Project/Properties/Application/Assembly Information/Make assembly COM Visible.
I am using the attribute ComVisible(true) to decide which class should be visible to COM on individual basis.
Visual Studio 2008 and Excel 2003-2008 required
Further details con be found on this post
Hi,
You can find attache a project that contains code that will allow you to create a C# COM exposed collection so that
1) It has Item as default property. So from VB 6.0 you can just do employees(1).Name
2) It is a IEnumerable object
3) It has a GetEnumerator() function that can be used to create VB 6.0 strongly typed collection that can be iterated using the For Each loop
Public Function NewEnum() As IUnknown
Set NewEnum = mNetList.GetEnumerator
End Function
Please do not to register the CLASS for COM interop just go to Project/Properties/Build Register for COM Interop.
Do not use the option Project/Properties/Application/Assembly Information/Make assembly COM Visible.
I am using the attribute ComVisible(true) to decide which class should be visible to COM on individual basis.
Subscribe to:
Posts (Atom)