Calling a function without an object
-
-
Hi.. I m developing a C# compiler for which i have a utility package. That package has lots of funtions. i want to call those functions without an object. and i don't want those functions to be static. how can i achieve this.. plz help me. regards, nas
why you want to cancel the (static) option ??
When you get mad...THINK twice that the only advice Tamimi - Code
-
why you want to cancel the (static) option ??
When you get mad...THINK twice that the only advice Tamimi - Code
-
becaus i want to call the function directly as:- ..... func1(); ..... and not as:- ..... className.func1(); ..... as we cal function in C..
maybe iam wrong, but i don't think that is possible. if you wrote a function on a class A and you want to access it from another class B then you cannot access it regardless class A.
When you get mad...THINK twice that the only advice Tamimi - Code
-
maybe iam wrong, but i don't think that is possible. if you wrote a function on a class A and you want to access it from another class B then you cannot access it regardless class A.
When you get mad...THINK twice that the only advice Tamimi - Code
-
anyway thanx for reply.. i hav another doubt.. i want to include a file, similarly as of #include. only i want to copy the code at the position where i call the function IncludeFile().
could you be more specific, i didn't understand the new question..
nasambur wrote:
only i want to copy the code at the position where i call the function IncludeFile().
this is not a professional way to do it , suppose you that you will use that code again, what will happen ?? you will copy the code again ??
When you get mad...THINK twice that the only advice Tamimi - Code
-
could you be more specific, i didn't understand the new question..
nasambur wrote:
only i want to copy the code at the position where i call the function IncludeFile().
this is not a professional way to do it , suppose you that you will use that code again, what will happen ?? you will copy the code again ??
When you get mad...THINK twice that the only advice Tamimi - Code
-
hmm. u r right.. i dont know exactly what happens behind when we use the 'using' in C#. plz explain me..
please Rewrite your question in order to understand your problem.
When you get mad...THINK twice that the only advice Tamimi - Code
-
becaus i want to call the function directly as:- ..... func1(); ..... and not as:- ..... className.func1(); ..... as we cal function in C..
Sorry, but what is the big deal about calling
ClassName.Func1()
? It is better to package these functions up in to an appropriate set of classes. It provides better logical separation.
Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: Introduction to AJAX (2nd May), SQL Server, Mock Objects Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website
-
anyway thanx for reply.. i hav another doubt.. i want to include a file, similarly as of #include. only i want to copy the code at the position where i call the function IncludeFile().
nasambur wrote:
i want to include a file, similarly as of #include.
C# has no need of that funtionality. If you want to be able to use classes, structs, etc. from other namespaces without having to refer to it fully each time use add the appropriate
using
directive at the top of the class file. You may also have to add a reference to the appropriate assembly that contains the code. To do this, right-click on the project you wish to add the reference to and select "Add Reference...". The dialog contains various tabs that indicate where the assemby is.
Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: Introduction to AJAX (2nd May), SQL Server, Mock Objects Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website
-
hmm. u r right.. i dont know exactly what happens behind when we use the 'using' in C#. plz explain me..
nasambur wrote:
i dont know exactly what happens behind when we use the 'using' in C#. plz explain me..
Using can be used in two places. In the context of this conversation you mean the way using is used as a directive to import namespaces into the current code file. Using allows the developer to call the class name on its own rather than be forced to use its full name. e.g.
using System.Data.SqlClient;
...
SqlConnection connection = new SqlConnection();or
System.Data.SqlClient.SqlConnection = new System.Data.SqlClient.SqlConnection();
Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: Introduction to AJAX (2nd May), SQL Server, Mock Objects Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website
-
please Rewrite your question in order to understand your problem.
When you get mad...THINK twice that the only advice Tamimi - Code
Actually, we are developing an application to test the User Load for any Website.. below is the script of our tool that loads virtual user and tests the site..
using System; using RTGWebLoad; namespace Coolgoose { public class Transaction { private string username; private string password; public void TransactionMain(RTGHttpBrowser wlHttp, string ThreadNum, long RoundNum, long MaxRounds) { wlHttp.BeginTransaction("Coolgoose_SendingMail"); CallCoolGooseSendMail(wlHttp, ThreadNum, RoundNum, MaxRounds); wlHttp.EndTransaction("Coolgoose_SendingMail"); } public void CallCoolGooseSendMail(RTGHttpBrowser wlHttp, string ThreadNum, long RoundNum, long MaxRounds) { if (RoundNum == 1) CGLogin(wlHttp); CGSM(wlHttp); //if (RoundNum % MaxRounds == 0) // CGLogout(wlHttp); } public void CGLogin(RTGHttpBrowser wlHttp) { string[] loginData = wlHttp.GetData("http://10.80.4.43/?get=userpass", ','); username = loginData[0]; password = loginData[1]; //username = "rtguser"; //password = "rtguser"; wlHttp.Get("http://www.cooltoad.com"); //wlHttp.CheckString("RTGian"); wlHttp.InfoMessage("Page1: " + wlHttp.wlSource); wlHttp.Get("http://www.cooltoad.com/go/email"); wlHttp.Get("http://www.cooltoad.com/account/login.php?mail=1"); wlHttp.ContentType = "application/x-www-form-urlencoded"; wlHttp.FormData("ACCOUNT", username); wlHttp.FormData("PASSWORD", password); wlHttp.Post("http://www.cooltoad.com/account/login.php?mail=1"); //bool bFlag = wlHttp.CheckString("This site uses frames"); // check string //wlHttp.InfoMessage(bFlag.ToString()); wlHttp.Get("http://www.cooltoad.com/common/header_email.php"); wlHttp.Get("http://as03.cooltoad.com/go/desktop?p=folders"); wlHttp.Get("http://as03.cooltoad.com/go/desktop?o=folder:inbox"); wlHttp.InfoMessage("------" + username + " logged IN ------"); //wlHttp.ErrorMessage("Error in Agenda"); } public void CGSM(RTGHttpBrowser wlHttp) { wlHttp.Get("http://as03.cooltoad.com/go/desktop?c=new"); string sCompose = wlHttp.FindString(wlHttp.wlSource, "COMPOSE\" VALUE=\"", "\">"); wlHttp.ContentType = "multipart/form-data"; wlHttp.FormData("TO", "xyz@gmail.
-
nasambur wrote:
i dont know exactly what happens behind when we use the 'using' in C#. plz explain me..
Using can be used in two places. In the context of this conversation you mean the way using is used as a directive to import namespaces into the current code file. Using allows the developer to call the class name on its own rather than be forced to use its full name. e.g.
using System.Data.SqlClient;
...
SqlConnection connection = new SqlConnection();or
System.Data.SqlClient.SqlConnection = new System.Data.SqlClient.SqlConnection();
Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: Introduction to AJAX (2nd May), SQL Server, Mock Objects Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website
-
Actually, we are developing an application to test the User Load for any Website.. below is the script of our tool that loads virtual user and tests the site..
using System; using RTGWebLoad; namespace Coolgoose { public class Transaction { private string username; private string password; public void TransactionMain(RTGHttpBrowser wlHttp, string ThreadNum, long RoundNum, long MaxRounds) { wlHttp.BeginTransaction("Coolgoose_SendingMail"); CallCoolGooseSendMail(wlHttp, ThreadNum, RoundNum, MaxRounds); wlHttp.EndTransaction("Coolgoose_SendingMail"); } public void CallCoolGooseSendMail(RTGHttpBrowser wlHttp, string ThreadNum, long RoundNum, long MaxRounds) { if (RoundNum == 1) CGLogin(wlHttp); CGSM(wlHttp); //if (RoundNum % MaxRounds == 0) // CGLogout(wlHttp); } public void CGLogin(RTGHttpBrowser wlHttp) { string[] loginData = wlHttp.GetData("http://10.80.4.43/?get=userpass", ','); username = loginData[0]; password = loginData[1]; //username = "rtguser"; //password = "rtguser"; wlHttp.Get("http://www.cooltoad.com"); //wlHttp.CheckString("RTGian"); wlHttp.InfoMessage("Page1: " + wlHttp.wlSource); wlHttp.Get("http://www.cooltoad.com/go/email"); wlHttp.Get("http://www.cooltoad.com/account/login.php?mail=1"); wlHttp.ContentType = "application/x-www-form-urlencoded"; wlHttp.FormData("ACCOUNT", username); wlHttp.FormData("PASSWORD", password); wlHttp.Post("http://www.cooltoad.com/account/login.php?mail=1"); //bool bFlag = wlHttp.CheckString("This site uses frames"); // check string //wlHttp.InfoMessage(bFlag.ToString()); wlHttp.Get("http://www.cooltoad.com/common/header_email.php"); wlHttp.Get("http://as03.cooltoad.com/go/desktop?p=folders"); wlHttp.Get("http://as03.cooltoad.com/go/desktop?o=folder:inbox"); wlHttp.InfoMessage("------" + username + " logged IN ------"); //wlHttp.ErrorMessage("Error in Agenda"); } public void CGSM(RTGHttpBrowser wlHttp) { wlHttp.Get("http://as03.cooltoad.com/go/desktop?c=new"); string sCompose = wlHttp.FindString(wlHttp.wlSource, "COMPOSE\" VALUE=\"", "\">"); wlHttp.ContentType = "multipart/form-data"; wlHttp.FormData("TO", "xyz@gmail.
Your mate is thinking the wrong way for C#. You can wrap this code in to a class library of its own. Then you can reference the class library from where it is needed, if it is needed in multiple projects.
Upcoming events: * Edinburgh: Web Security Conference Day for Windows Developers (12th April) * Glasgow: Introduction to AJAX (2nd May), SQL Server, Mock Objects Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website