.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

CLASS question

Posted By:      Posted Date: September 29, 2010    Points: 0   Category :ASP.Net

Hi guys!


I have a class like this:


namespace Core.Utils
    public class getText

        public string getText(string ext){

            string result = "The String: " + ext
            return result;



Normally, I use it like this:


var xx = new getText();

var yy = xx.getText("AAA");



I want to know how to be able to use it like this:


var yy = new getText("AAA");


It's that possible?

Thanks in advance!


View Complete Post

More Related Resource Links

Question on a class that is reused


I have a generic class that just has the following:

    public class GenericMap

        private int _Number_1 = 0,
                    _Number_2 = 0,
                    _Number_3 = 0,
                    _Number_4 = 0,
                    _Number_5 = 0,
                    _Number_6 = 0,
                    _Number_7 = 0,
                    _Number_8 = 0;
        private string _String_1 = string.Empty,

Design Question - Child Class Reference


There has to be a better way to design the following:

public class Member {
  public int stateID {get; set;}

  public State state {
    get {
      if (this.stateID > 0) 
        state = State.GetByID(this.stateID);

public class State {
  public string name {get; set; }

  public static State GetByID(int id) {
    //populates state from db

Now if I loop through a list of members and need to display the state name for each member and I call "myMember.State.name" - I'll get the name of the state but it costs me an extra query everytime I call that - even though some of the states may be the same.

Is there a way somehow keep some sort of cache of state name from the db for access?


Binding Question How does one set datacontext to same class in XAML?


I have a usercontrol with one button in it.  I want to set the text via a property getter setter using the INotifyPropertyChanged interface in code behind.  I can get it to work if I set the DATACONTEXT in code behind in the CTOR like this : DataContext = this;  Everything works perfect. 

But here's the problem.  If I try to do this in xaml by defining an XMLNS which points to the folder this usercontrol is in, and then attempt to reference it as a resouce like this <local:XXXXXX  <-------The XXXX which is the class name of this control can't be found?  Is that wierd?  Can't a resource be itself?  So that I can set the Datacontext in the XAML instead of code behind?  I've tried to bind to relative source self, but cannot set the property (Event when I attempted to created a dependency property).....  Just wondering how one sets up Datacontext to the same class? 


Class Design Question



I have a question about class design. Currently I am working with following tables:

| Forms
| FormID (PK)
| CommitmentID (FK)
| ...

| Commitments
| CommitmentID (PK)
| CommitDesc
| ...

| Pricings
| PricingID (PK)
| Desc
| CommitmentID (FK)
| ...

| PricingTiers
| TierID (PK)
| PricingID (FK)
| Desc
| ...

Forms <-one to one-> Commitment
Commitment <-one to many-> Pricing
Pricing <-one to many-> PricingTiers

When designing the classes what would be considered a best practice ... for instance at the moment I have 4 classes "Form", "Commitment", "Pricing", and "PricingTier" respectively.

Form class has a public property Commitment which represents an instance of the Commitment class.

Commitment class has a public property List<Pricing> which represents the one to many (Commitment - Pricing) relat

Data Class Best Practices Question


Hi all.

I have a class called employee.  I have several private fields (i.e. mHiredDate, mSickDays, mVacationDays, etc.).  I instantiate employee objects thru out my website application.  When I make a change to the private fields using the public property set method, is it a better practice to make the changes thru out the session and save the values back to the database near the end of the session or make the set make the change to the database everytime it is called?  Does the same go for get ?  Do I have my get goto the database and grab the value everytime I need it ?

I hope my question is clear enough. 

Thanks Smile


Question About singleton class


Just wanted to know if a singleton class could be inherited and derived.


Question on WorkflowApplication class design ( Func Properties)





I found out that the Workflow Application class offers Func<T> properties to inject code for example when a error occurs.

whats the reason behind the Design Decission of giving the WorkFlow Foundation class Func<T> properties instead of event?


For Example


 Func<WorkflowApplicationUnhandledExceptionEventArgs, UnhandledExceptionAction> OnUnhandledException { get

; set

; }





 Action<WorkflowApplicationCompletedEventArgs> Completed { get

; set

; }


Is it just to prevent the multiple receipients ?

Or is it related to memory mangement due to fix pins caused by eventhandlers ? To be honest i must confess that i'm not sure wether Func<T> will created a fix pin in memory :-(

I'm not sure about if this is good or not, but it would be very nice to get knowledge of the reason why this class is event

debug and class diagram question, visual studio 2008


Hi. Im working on a project where there are a lot of imported dll's from a company that have e-soultions. now some times when i debug i get to a dead end when a class or method is used from their project. They supplied me with their sourcecode so i got that, now the question is can i somehow debug in my main project and to trace it to their project if i got the source code? (hope im clear on what i want to do)


second question is that i want to print all the classes and inherits, can i get that somehow with the different relations between classes straigh out of visual studio? i know about class diagram but it dont show relations.


thanks for reply

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.

Creating a Simple Class in C#

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

Static Class for Beginners

In general, the members of a class can be accessed by instance of that class when they are in public, but there comes a situation to access or call members of a class without an instance and this can be achieved by declaring them as static

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.

MessageQueue Class

This sample demonstrates two way communications using message queuing between a device application and a desktop application. One application sends book order messages to a message queue and another application receives these book orders from the message queue and responds to the device queue that the orders have been processed.

Some basic MVC question

  1. In regular asp net I can run (debug) the application but I can either "view in browser" that gives me the option to view the application and write code on same time.

In MVC I can't find this option.

  1. What is the basic DATA MODEL for working with SQL DB.

I mean with no any framework (entity framework, Sub sonic, Link to SQL etc')

I look for basic application that works with data but with no fw.

  1. What is the popular DB framework that working with data.
  2.  I am looking on  mvc series


C# Soup To Nuts  (the best series ever)


I watch some of the MVC video, seems that the music store is good but I have to wait to the other part.

Does any one know and recommend   a Microsoft MVC tutorial?





Web Site to Web Application Question


I've been building web sites and for my next project I will be creating a web application.  I use a 'BasePage' class in all my projects but, since web applications do not contain the 'App_Code' folder, what is the best place/practice for the 'BasePage' class?



connection string question from a newbie


when publishing  in the webmatrix dialogue it asks for "destination connection string" for my "database.mdf"

I was not sure what it was so I pasted this from my web.config file :

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\database.mdf;Integrated Security=True;User Instance=True

it all published ok, but wont run, so I guess it has somthing to do with this connection string or some kind of configuration issue.

My question is this, What should go in the field for "Destination connection string"

How to change the default page base class?


I've tried setting the <pages pageBaseType="DynamicWebPage" /> value in web.config, but when I response.write out the page type, I'm still getting Microsoft.WebPages.WebPage.

I'm simply trying to sub-class WebPage and add some additional functionality such as a dynamic PageData dictionary similar to Phil Haack's dynamic ViewData dictionary.



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