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

Top 5 Contributors of the Month

Home >> Interview Question >> C# >> Post New Question Subscribe to Interview Questions

How to pass a value from a method to a property procedure in c# win application?

Posted By :Sameer     Posted Date :April 14, 2010    Points :10   Category :C# 
Here is my code:

class Jewellery : Connectionstr

string lmcode;

public string LM_code//Here i want to access the value of the method(ReadData) i.e displaystring and store the value in to the insert query below.
get { return lmcode; }
set { lmcode = value; }


string mname;
public string M_Name
get { return mname; }
set { mname = value; }

string desc;
public string Desc
get { return desc; }
set { desc = value; }

public string ReadData()
OleDbDataReader dr;
string jid = string.Empty;
string displayString = string.Empty;
String query = "select max(LM_code)from Master_Accounts";
Datamanager.RunExecuteReader(Constr, query);

if (dr.Read())
jid = dr[0].ToString();
if (string.IsNullOrEmpty(jid))
jid = "AM0000";
int len = jid.Length;
string split = jid.Substring(2, len - 2);
int num = Convert.ToInt32(split);
displayString = jid.Substring(0, 2) + num.ToString("0000");
return displayString;//I want to pass this value to the proeprty proc above i.e LM_code.

public void add()

String query ="insert into Master_Accounts values ('" + LM_code + "','" + M_Name + "'," + "'" + Desc "')";
Datamanager.RunExecuteNonQuery(Constr , query);


You can also find related Interview Question to How to pass a value from a method to a property procedure in c# win application?  below: 

How do I call a member method and pass a primitive type (Value Type) by reference?

Use the ref keyword when declaring the parameter of the method, for example:

public bool GetValue( ref int returnValue );

This will pass the numeric by reference.You can modify the value of returnValue within the body of GetValue and it will persist when the method call returns. (More...)

How can I look up a parent class method or property of any System-level object?

Use the Class View window, accessed from the standard toolbar by clicking View | Class View. (More...)

How to pass the arguments in thread by passing the arguments in start() method.

Thread t1 = new Thread(new ThreadStart(obj.abc));
t1.Start(21); (More...)

What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control?

Set the DataMember property to the name of the table to bind to. (If this property is not set, by default the first table in the dataset is used.)
DataBind method, use this method to bind data from a source to a server control. This method is commonly used after retrieving a data set through a database query.

How would you pass user credentials while using SharePoint WebService from your Web Part or application.

Ans. The web service needs credentials to be set before making calls.


listService.UseDefaultCredentials = true; // use currently logged on user

listService.Credentials = new System.Net.NetworkCredential("user", "pass", "domain"); // use specified user (More...)

How do you call a Member method and pass a value Type by reference?

use the "ref" keyword when declaring a Parameter of the Method
public bool GetValue(ref int returnvalue);

How do you call a Member method and pass a value Type by reference?

use the "ref" keyword when declaring a Parameter of the Method (More...)

What is Application Domain?

The primary purpose of the AppDomain is to isolate an application from other applications. Win32 processes provide isolation by having distinct memory address spaces. This is effective, but it is expensive and doesn't scale well. The .NET runtime enforces AppDomain isolation by keeping control over the use of memory - all memory in the AppDomain is managed by the .NET runtime, so the runtime can ensure that AppDomains do not access each other's memory.
Objects in different application domains communicate either by transporting copies of objects across application domain boundaries, or by using a proxy to exchange messages.
MarshalByRefObject is the base class for objects that communicate across application domain boundaries by exchanging messages using a proxy. Objects that do not inherit from MarshalByRefObject are implicitly marshal by value. When a remote application references a marshal by value object, a copy of the object is passed across application domain boundaries. (More...)

What is Method overloading?

Method overloading occurs when a class contains two methods with the same name, but different signatures. (More...)

What is Method Overriding? How to override a function in C#?

Use the override modifier to modify a method, a property, an indexer, or an event. An override method provides a new implementation of a member inherited from a base class. The method overridden by an override declaration is known as the overridden base method. The overridden base method must have the same signature as the override method.
You cannot override a non-virtual or static method. The overridden base method must be virtual, abstract, or override. (More...)

Can we call a base class method without creating instance?

Its possible If its a static method.

Its possible by inheriting from that class also.

Its possible from derived classes using base keyword. (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.

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