.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

C# 2.0: Create Elegant Code with Anonymous Methods, Iterators, and Partial Classes

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

C# 2.0 introduces a wealth of exiting new features, such as generics, iterators, partial classes and anonymous methods. While generics are the most talked-about feature especially for former classic C++ developers, the rest of the new features are important additions to your .NET development arsenal, enhancing power and improving overall productivity. This article is dedicated to all the new C# 2.0 capabilities besides generics to give you a good overall picture of the upcoming features.

Juval Lowy

MSDN Magazine May 2004

View Complete Post

More Related Resource Links

C#: Create Elegant Code With Anonymous Methods, Iterators, And Partial Classes


In this article Juval Lowy describes how exciting new features in Visual Studio 2005, that will improve your overall productivity compared to the first version of C#, so you can write cleaner code faster.

Juval Lowy

MSDN Magazine Visual Studio 2005 Guided Tour 2006

Code behinds in MVC2 - How to inject auto-generated code into views via partial classes?

Background:I have written a t4 template that basically replaces the work done by StronglyTypedResourceBuilder to give design time access to string resources as properties of classes, one class per resource file.  Why?  Well I needed to add some customer code that handles string token substitution and a few other customizations.  Anyway, the template is working out really well and I may blog on it soon.In the mean time though, following a common pattern, I have one .resx file for each view, master page, controller, etc.  I would really like my t4 template to add a property to each such entity that gives quick access the custom resource class associated with it.  For controllers this is easy.  T4MVC is ensuring that they are a all declared partial.  All I need to do is create the appropriate partial class in my output that declares a readonly property that returns an instance of the appropriate generated resource class.The Problem:I would like to do the same thing, inject generated code, into my views.  Were this traditional ASP.Net, each .aspx page would have a .aspx.cs page and possibly an .aspx.designer.cs page that are all partial classes extending in the aspx page's class definition.  There is no such thing by default in MVC and for good reason.  However, I think for my purposes, if there is a way to do this, it

Create/add table from code to database



I create table:

                  DataSet data=new DataSet();

                  DataTable myTable = new DataTable("NewTable");

                   DataColumn[] keys = new DataColumn[1];

                   // create column
                   keys[0] = new DataColumn();
                   keys[0].DataType = System.Type.GetType("System.String");
                   keys[0].ColumnName = "PointID";
                   myTable.Columns.Add(keys[0]);    &nb

Code Name Avalon: Create Real Apps Using New Code and Markup Model


The presentation subsystem in the next version of Windows, code-named "Longhorn," offers powerful new capabilities to developers. This subsystem, code-named "Avalon," allows developers to take advantage of its capabilities through a new markup language code-named "XAML." In addition, modern object-oriented programming languages such as C# and Visual Basic .NET can be used to tie everything together. Because most applications written to Avalon will probably be a mix of XAML and programming code, this article discusses XAML tags used to control page layout along with the procedural code written to respond to events.

Charles Petzold

MSDN Magazine January 2004

C++ and ATL: Use ATL Server Classes to Expose Your Unmanaged C++ Code as an XML Web Service


Throughout this issue, you'll read all about the promise of Web Services and how the .NET Framework enables Web Service development. Many people will also be building their Web Services atop C++ code and frameworks like ATL Server, particularly when performance is paramount. In this article, the authors show how fully functional Web Services are built using ATL Server and Visual Studio .NET. Beginning with unmanaged C++ classes, they add ATL attributes that make the code work over HTTP.

Kirk Fertitta and Chris Sells

MSDN Magazine December 2002

Create databound nested ajax toolkit accordion programatically(In code Behind)


Can anyone guide me in the right direction or give an example of How I would accomplish this?


I have  this so far but kind of stuck on how to do it programtically if I'm using header and content templates 

I have a xmldatasource.. In a nutshell at what point in my code do I need to create a new accordion? does it need to be

in the item_databound handler?


Imports Microsoft.VisualBasic

Public Class AccordionTemplate
    Implements System.Web.UI.ITemplate

    Dim templateType As String

    Sub New(ByVal type As String)
        templateType = type
    End Sub

    Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) _
          Implements System.Web.UI.ITemplate.InstantiateIn

        Dim ph As New PlaceHolder()

        Select Case (templateType)
            Case "Header"
                Dim myLabel As Label = New Label()
                myLabel.Text = "Test"
            Case "Content"
                ph.Controls.Add(New LiteralControl("<p>hello</p>"))
        End Select
    End Sub

End Class



Partial Class Accordion
    Inherits System.Web.UI.Page


Create a Outlook Task from Custom WebPart in Code



I have a requirement to create a Outlook Task , from a custom webpart through code .

Is this possible?

has any body tried this , if yes can you please give me an insight on how to acheive it.

Some sample Code would be highly appreciated.



create a dynamic view on code

How i can create a new view on code (on runtime) if this view dont exits?   Thanks

Create longer than 4 characters Soundex Code

Hi all, Does anyone know if it is possible to create a soundex key that is longer than the standard 4 characters? I guess if it doesn't then you just have to create a user defined function? I'm trying to do address matching on a table of customers 3 million records. I was thinking of embarking on full text search if it is not possible. Anyone with any advice always gratefully received. Cheers Ant

Getting CSS classes in code

Hi All,I am working on a web application that has multiple themes. The development is parallely being done on all of them. Since I have multiple themes, I have multiple set of CSS files. I doubt that some classes are missing in some of the CSS files.Is there any way to programatically get the CSS classes and check whether all the classes are present in all the files ?Thanks,Girish.

how do I create/show modal form using the following code?

The text contained in a .txt file loaded with the following code doesn't show up in the RichTextBox control on a separate form which has been instantiated and launches sucessfully.  Why don't the contents of the .txt file show up in the RichTextBoxControl on the instantiated form?  Thank you for ideas! private void ToolStripMenuItemOpenAlarmHistory_Click(object sender, EventArgs e) { OpenFileDialog openFile1 = new OpenFileDialog(); FormAlarmHistory_Loaded_Into_RichTextBox formAlarmHistory; openFile1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; if(openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK && openFile1.FileName.Length > 0) { using (formAlarmHistory = new FormAlarmHistoryLoadedIntoRichtTextBox()) { dialogResult = formAlarmHistory.ShowDialog(); if (dialogResult == DialogResult.OK) { formAlarmHistory.richTextBoxPrintCtrlForLoadedAlarmHistory.LoadFile(openFile1.FileName); } } } }

Does anyone know how to create a page that has Code behind in Sharepoint.

I am creating a page that will need some controls for dropdowns and radio buttons etc and I need to know if and how to setup and create a page in Sharepoint that has the code behind to handle click events, onselectedchange like .NET does.

Create DLL from C code using Visual Studio 2005

I have a commercial application (ZEMAX) that uses DLLs to describe problem geometry.  They provided source code in C for one of their DLLs.  I would like to modify that source code and generate a modified DLL.  Can I do that with Visual Studio 2005 (how?) or do I need a different IDE?

create a form to create an ascx page and code behind for it

Is is possible to build a form, accept parameters and from THAT construct a new .ascx page AND the code behind for that page? What I'm proposing is having some code snippets that just need parameters added and can then be used to create a web user control that can be added to existing pages. This .ascx file would be a real file after creation, not dynamic every time.I don't know if I'm describing it very well, maybe someone could point me in the right direction.

How to dynamically create HTML file from the code ?

Hi all,Precisely and concisely, I have aspx page that has only one button "Generate". If the user clicked on this button, one HTML page should be created. The created HTML page should have title "Home" and the Body should contain "Hello World". 1) What is the code that should be written inside "Generate" button in order to accomplish this functionality? 2) Assuming the HTML page gets created, How to store it inside specific folder on the local drive? Or how to store it inside DB? I would greatly appreciate any constructive input!

Create new aspx-page from code


Hello everyone.

I'm am looking for a general idea about the following:


My customer is looking for an application - a sort of webshop-like thingie, where each product has its own infopage with a unique URL.

He does NOT want an actual CMS.

I could - and probably will - use querystrings, like http://www.example.com/products.aspx?pID=21, and then get the content from the database, but is it possible - or rather possible without too much bother - to let the administrator input text via a webform, and then form code create a contentpage like http://www.example.com/product21.aspx

Have a nice weekend



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend