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


Post New Web Links

cant access class variables

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

hi all see the code below

using System;

 class mymainclass
{
    int a;
    int b;
}

 class calculation
{
    public static void Main()
    {
        calculation cl = new calculation();
        cl.getinput();

        int m = cl.getresults(5, 10);
        Console.Write(m);
    }

     int getresults(int a, int b)
    {

       
        int c;
        c = a * b;
     
        return c;
    }

    void getinput()
    {
        Console.WriteLine("Enter first no");
       mymainclass mc = new mymainclass();
        
        Console.WriteLine("Enter second no");
    }


View Complete Post


More Related Resource Links

BinaryFormatter, SortedSet base class and a few instance variables.

  
/* This example successfully serializes and deserializes the SortedSet<string> base contents, but all the instance variables show up uninitialized. Here's the output: n1: 0 n2: 0 str: s == "String 1" s == "String 2" s == "String 3" Any ideas? */ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization; using System.IO; [Serializable] public class MyObject : SortedSet<string> {     public MyObject() : base() { }     protected MyObject(SerializationInfo info, StreamingContext context)         : base(info, context)     {     }     public int n1 = 0;     public int n2 = 0;     public String str = null; } namespace BasicBinarySerializationInheritanceFromSortedSet {     class BasicBinarySerializationInheritenaceFromSortedSetTest     {         static void Main(string[] args)         {             {                 MyObject obj = new MyObject();   &nb

Access a user created class in the form code

  
Hi Dear i have a litle problem i am developing a database application. In this app i write made two projects in the same solution. 1st named BussinessData and the 2nd one has a name Database Application. in business data i have add a libary class and made its region for easily code writing. now i want to get access at that class code from the application form code. example: sum of two numbers pubic class Sum #region "Public variables" dim a,b,c as integer #end region ' seperate region for getting values #region "Properites" public property a() as integer Get  return _a Set (by val value as sender)         _a=value end property #end region 'region for sum #region "Methods" public function sum() as integer c=a+b return c end function #end region in this way i have written the code and i want to get access this class from the form code. 'button_click code for the sum sum() plz help me to solve this problem  

how i can access a user created class in form code

  
Hi Dear i have a litle problem i am developing a database application. In this app i write made two projects in the same solution. 1st named BussinessData and the 2nd one has a name Database Application. in business data i have add a libary class and made its region for easily code writing. now i want to get access at that class code from the application form code. example: sum of two numbers pubic class Sum #region "Public variables" dim a,b,c as integer #end region ' seperate region for getting values #region "Properites" public property a() as integer Get  return _a Set (by val value as sender)         _a=value end property #end region 'region for sum #region "Methods" public function sum() as integer c=a+b return c end function #end region in this way i have written the code and i want to get access this class from the form code. 'button_click code for the sum sum() plz help me to solve this problem

Access ViewState in Class File

  
The article Access ViewState in Class File was added by bhaarat on Wednesday, September 01, 2010.Many times we might need to access Viewstates in classfilewhich is not availablethis is a way to access the Viewstte in Class fileon code Behind%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits

Need to access session variables in an ashx?

  
Dear All,In my project i need to set session in an ashx file and access that session in aspx.cs file. for this i am dooing the following things.In .ashx filepublic class Upload : IHttpHandler , System.Web.SessionState.IRequiresSessionState{    public void ProcessRequest(HttpContext context)    {            HttpPostedFile postedFile = context.Request.Files["Filedata"];            context.Session["img"] = postedFile.FileName;    }}After the file upload happand i wrote the code in .aspx.cs fileprotected void Button1_Click(object sender, EventArgs e)    {        Response.Write(Session["img"].ToString());    }this is working fine in IE but in Mozilla,Chrome,safari and Opera i got Session["img"] is null. Any help can be appreciatedThanks & Regards Basheer K M Cybrosys Technologies Pvt. Ltd. Calicut. http://www.cybrosys.com

Not able to access Class methods when deployed on a remote server?

  
I have a web service project. In the project I have a class named "Piper"In testing the web service in localhost mode in the VS IDE, I can access membersof the class, such as my method "Proceed" and property "Comber" The problem I am having is that when the web service is deployed to the serverin staging, or the deployment server, I am not able to access any methods of my class. Onlythe properties. This is very strange? As they are both public and I can access them when I run the project in local host in the IDE. Does anyone know what the problem might be?Here is a simplified example of my class. Public Class Piper Public Sub Proceed() End Sub Public Property Comber() As Boolean  Get   Return True  End Get  Set(ByVal value As Boolean)       _comber = value  End SetEnd Property End Class

Sharing of Non-Static member variables of a class using .NET Remoting

  
This kind of weird. I am trying to host an object of a class X (a class library class). This is a SAO and I have set the WellKnownMode as Singleton in the server configuration. <wellknown mode="Singleton" When multiple clients fetch the instance of the class X they can share the static member variables. Any changes made to the static variables are visible to each other. The problem is with the non-static member variables of the class. Each instance is having a local copy of the non-static variables. Why should that happen in case of a Singleton mode? Am I missing something for which this is happening? Any help will be appreciated.  A for apple, B for boy, C for c++

How can I access a webform control from another external class/namespace?

  

Currently, I have many controls and objects such as Chart1 of mschart as part of the public partial class _Default : System.Web.UI.Page.


At the bottom, I've created a second class that is not part of the _Default webform class.  How can I access the webform controls from this second class?

For example, I want to do

Chart1.Series["Series1"].Points.AddXY((pointIndex + 1) * 40, datapoints[pointIndex]);

I want to pass pointIndex integer and the datapoints array.

I know that Chart1 was created protected global access modifier in the designer.cs but when I changed it to public, it still had a problem.


Thanks


Accessing variables containing usercontrols in a partial class

  

Hello everyone,

Last night you guys here on this forum helped me in accessing properties of a dynamically loaded UC in an aspx page. Now i am facing another hiccup.

My code behind is : public partial class SiteUserControls_Message_Messages : BaseControl

In one of the click events i am loading three web users controls:

protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)
{

         SiteUserControls_Message_Create CreateNewMessageUC = Page.LoadControl(CreateMsgControl) as SiteUserControls_Message_Create; // typecasting the UC

}

Now i want to access this variable CreateNewMessageUC in another event like this:


protected void MarkAsUnreadLinkButton_OnClick(object sender, EventArgs e)

{

      CreateNewMessage.CreateNewMessageUC.RefreshSendTo();

}

In My effort to make the UC variable global i have put that in class body liek this


public partial class SiteUserControls_Message_Messages : BaseControl
{

       SiteUserControls_Message_Create CreateNewMessageUC;

       .............................

But when i access teh variable in another event i

Can't access App_Code class in Code Behind file

  

I have a class defined in the App_Code subdirectory:

namespace WebApplication9_App_Code
{
  public class Class1
  {
  }
}

And I have a code behind class default.aspx.cs:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace WebApplication9
{
  public partial class _Default : System.Web.UI.Page
  {
    protected void Page_Load(object sender, EventArgs e)
    {
      WebApplication9_App_Code.Class1 cls1;
    }
  }
}

I get the following compilation error:

The type or namespace name 'WebApplication9_App_Code' could not be found (are you missing a using directive or an assembly reference?)

What am I doing wrong? 

Thanks very much for your help.


how to access the Poperty class

  

Hi Guys,

           Greetings for the day,Actaully i am careted one webservice name:service1,created one more class name: service2 this poperty class for webservice,My question is

1.How to access that property class in client side?

2.It's possible to create Layer archt. Inside the webservice?

Thanks for you help

Ranganathan Palanisamy  


How do I Access Variables Between Custom Activities From Code?

  

Basically, I have custom activity and I have a variable in it that I would like to access in another custom actvity. It it possible to do this without writting the acutal workflow from code and still use the designer? The best way to describe it would be that I want to declare a global variable from within an activity that would be available to any other activity.

This is an example of what I am trying to:

public class activity1 : NativeActivity
  {

    protected override void Execute(NativeActivityContext context)
    {
      string text = "Sent between activities!";
      context.Properties.Add("globalText",text);
    }
  }

And here is the activity in which I would like to get the contents of the property:

 public class activity2 : NativeActivity
  {
    
    protected override void Execute(NativeActivityContext context)
    {
      string text = "";
      text = Convert.ToString(context.Properties.Find("globalText"));
      
      Console.Write(text);
    }
  }

Stepping through the code shows that the "context" object has zero properties once I enter the second activity. According to different sources this should be working because the context object should still contain my property correct?


Access Class in a Webservice

  

Hello,

I add a web reference and in this webservice their is a class inside the Reference.vb. How do I access this class inside the webservice?


-imperialx


Access class

  

How do i access derived class?

What I have is: 

public interface IPen:IEraser
    {
        String Name { get; set; }
        List<IInk> Ink { get; set; }

    }

public interface IInk : ISomething
    {
        IPencil HaveInk { get; set; }
        bool IsRed { get; set; }
        bool IsBlue { get; set; }
        bool IsBlack { get; set; }
    }


I Also have associated classes with this interfaces. How do I access IsRed/IsBlue/IsBlack properties?

When I create new Pen object I can access Name property, but when i try to assing value to [Ink.IsRed] I am getting exception: object referenece not set to an instance of object


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.

MVC architecture in ASP.Net using C# and Microsoft Data Access Application block

  
The Model-View-Controller (MVC) pattern separates the modeling of the domain, the presentation, and the actions based on user input into three separate classes [Burbeck92]:

Model. The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller).

View. The view manages the display of information.

Controller. The controller interprets the mouse and keyboard inputs from the user, informing the model and/or the view to change as appropriate.

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
Categories: 
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