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

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

Creating a Simple Class in C#

Posted By: Amit Mehra     Posted Date: December 18, 2009    Points: 2   Category :OOPS
The second article in the C# Object-Oriented Programming tutorial describes how classes are created in C# and how behaviour, in the form of publicly visible and private, hidden methods can be added. This demonstrates some of the uses of encapsulation

View Complete Post

More Related Resource Links

Creating a Validator class for a custom activity

I created a new Workflow Activity Library and then added a new Activity called BindForm2Activity. After that I added a new class called BindForm2Validator and then placed an attribute to the BindForm2Activity to link it to the validator class.   Here is the code for each of the classes:   BindForm2Activity.xoml.cs: Code Snippet   using System;using System.ComponentModel;using System.ComponentModel.Design;using System.Collections;using System.Drawing;using System.Linq;using System.Workflow.ComponentModel.Compiler;using System.Workflow.ComponentModel.Serialization;using System.Workflow.ComponentModel;using System.Workflow.ComponentModel.Design;using System.Workflow.Runtime;using System.Workflow.Activities;using System.Workflow.Activities.Rules; using FormsCollection;using Utils; namespace ActivityLibrary{    [ActivityValidator(typeof(BindForm2Validator))] public partial class BindForm2Activity : SequenceActivity {        public static DependencyProperty FormToBindProperty = System.Workflow.ComponentModel.DependencyProperty.Register("FormToBind", typeof(FormsCollection.Form2), typeof(BindForm2Activity));         [Description("Form to bind a datasource to it ")]        [Category("BindForm2ToDataSource")]        [Browsable(true)]        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]        public FormsCollection.Form2 Form

FAQ: How do I use the SerialPort Class for simple serial communications?

How do I use the SerialPort Class for simple serial communications?Please remember to mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.

Tips For Creating simple game .net

Hi. I am developing a simple backgammon. i Designed 3 picture for the game. 1) Black not as png format 2)white not ==>png format 3) board jpg i have sum question about designing game. i want to create it with .NET Framework 4. probably windows application. I'm a bit familiar with wpf but not much. what is the best way for putting png nut on the jpg board? picturebox ? in attention of first question how can i move nuts on board? if possible give me some tips about developing this game. thanks

Some help needed for creating a new "struct" to represent elements of a class in a different way....

I'm working on an existing project, where a class is defined as follows:  public class Stat { public DateTime? Date { get; set; } private Dictionary<string, int> _pageViews; public Dictionary<string, int> PageViews { get { if (this._pageViews == null) this._pageViews = new Dictionary<string, int>(); return this._pageViews; } } where the dictionary will store, for each entry, the name of a browser (string) and the # number of pagevisits using that browser(int). So basically, it's like a database table with 3 fields {Date, browser, count} (Each instance of the class is like a record within the table).   What I'm looking for is a way to create a new structure in which the pair {browser- Date/Count}  becomes the PK in DB terms.   Browser        Date                Count--------------------------------------------- Firefox         08/08/2010         20Firefox         08/09/2010         12IE                08/08/2010    

Creating class in controller

I am using vs 2010, mvc, linq to sqlMy Model is .dbml filetbl_teacher,tbl_class,tbl_subject etc are involvedI write code in my controller for table join.public ActionResult Index() { var DataContext = new SMSAPPDataContext(); var result= from t in DataContext.tbl_teachers from e in DataContext.tbl_teacherenrollments from b in DataContext.tbl_batches from c in DataContext.tbl_classes from s in DataContext.tbl_subjects where t.Teacher_ID == e.Teacher_ID && e.Batch_ID == b.Batch_ID && b.Class_ID == c.Class_ID && e.Sub_ID == s.Sub_ID && t.Teacher_Name == "ABC" select t; return View(result.ToList()); I am passing Teacher Name in query and want to get result from two tables , from class & Subject.But, When i create view i can only select one table i.e. tbl_classNow i decided to create a class in controller. I Want to call both my tables in here. A new Model Classnamed MyViewModel will be  created, and I will pass this mod

Questions about creating a class that returns multiple values


Hey all,

I am a little stumped, been trying to find some references to this but I am coming up with more confusion than anything else.lol

Here is my scenario using asp.net and VB.

I have an aspx page with about 10 label controls on it and a couple of image controls. Their data will be all populated dynamically by a single URL query string that is passed to a 3rd party url query string that retrieves an xml document with all of the information on it. I am currently just using the page load event and from that I can get everything I need and populate the page elements no problem with all of the code existing on the aspx.vb page.

However I thought for this project as I go forward I would like to create a vb class that handles all of the work instead of using the code behind page which has become quit convoluted.

I am not completely new to creating classes, I've done them before, and some pretty complex however this one is new due to the fact that I want to return multiple values.

So my thought is to approach it this way.

1.       On the page load event I grab the URL query string, and pass it to the vb class to begin the process.

2.       In the class I create a function that loads the xml document into memory.

3.     &n

Serializing a simple class as a single node, not a sub node!


While I have not bothered about this earlier I am going to need to get this sorted asap now that we are building a large Persisted (File System Based) Data Store.

The code below as it is will output this XML File contents

<?xml version="1.0"?>
<SimpleSerializationObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

Regarding Creating Custom Field type Class Inheriting from IFieldEditor Interface and UserControl C


How to enable the hidden labels On Create Column Page after selecting our Custom Field type before just ckicking OK so that all those labels appear.

Creating a simple XML Parser alternative to LINQ

The article Creating a simple XML Parser alternative to LINQ was added by codenickel on Saturday, October 30, 2010.

Creating a simple XML Parser alternative to LINQ Here is a simple way to parse an XML string, and store its element name and values in a Hashtable which you can call its key using the GetAttribute() method. public class Parse { Hashtable attributes; public

Sample: Creating Simple Web Part Mashups with InfoPath 2010

Explore the code as you learn to create a simple Web Part mashup on SharePoint Server 2010 with InfoPath 2010 and the InfoPath Form Web Part.

Creating a Simple Web Part Mashups with InfoPath 2010

Learn how to create a simple Web Part mashup on SharePoint Server with InfoPath and the InfoPath Form Web Part.

Creating a new Chart Object Inherited from the base chart class with New Initial Settings


I'm creating a new chart object andI want to modify some of the members based on ways that I perfer to use the tool.

At present when I drag and drop my new chart object onto a form, it comes in with the same initial values as the original chart object.

How do I change these initial values?

For example the ChartAreas Collection comes populated with "ChartArea1." I'd like to change this to always say "MyChartArea" along with my specific properties pre-populated (e.g. BorderWidth= 2).

Does anyone know how to do this?

Creating your SharePoint Governance Plan

One of the most common questions that I get from prospects as I'm talking to them about the creation of a governance plan and process is what does it look like. In other words, there are materials available which describe what should be in a governance plan but there isn't a ton of guidance on what the process of creating a governance plan and process are.

Creating Paging for a Repeater Control

A common question is "How do I implement paging within a Repeater?" Although the beauty of the Repeater control is its flexibility, you're on your own for building most functions. ASP.NET 2.0 has included some new controls that provide paging, as does the DataGrid in ASP.NET 1.1. However, this tip shows you how to roll your own paging for a simple data viewer.

Creating an AJAX Repeater in ASP.NET MVC

The "TaskList" is a tried an true example of the most basic thing that you can do in any framework. Unfortunately, I had some problems finding a really good example of all the steps necessary to get a task list to work in ASP.NET MVC 1.0.

Creating a Generic Entity Framework 4.0 Repository

With .NET 4.0 right around the corner, I thought it would be cool to download Visual Studio 2010 beta 2 and start playing around with the next release of Entity Framework.

The initial release of Entity Framework came with a great deal of criticism. To make matters worse, there was a large uproar when it was rumored that Microsoft would be abandoning LINQ to SQL, in favor of Entity Framework. This was because, at the time, many developers felt Entity Framework was an inferior technology to LINQ to SQL. To set things right, Microsoft proactively moved forward with improving Entity Framework, in time for the 4.0 release of the .NET Framework. This is good news because my initial impressions, so far, have been nothing but positive.

Class Diagrams

Class diagrams show the static structure of the systems. Classes define the properties of the objects which belong to them. These include:

Attributes - (second container) the data properties of the classes including type, default value and constraints.
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