473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,406 developers and data experts.

Use CallByName in C#

First add to referance Microsoft.VisualBasic

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Microsoft.VisualBasic;
  5. using Microsoft.VisualBasic.CompilerServices;
  6.  
  7. namespace CallByNameConsole
  8. {
  9.     class _TEST
  10.     {
  11.         private string _STR = "Called By The Name";
  12.  
  13.         public string _TESTSTR {
  14.             get {
  15.                 return _STR;
  16.             }
  17.             set {
  18.                 _STR = value;
  19.             }
  20.         }
  21.         public string _FUNCTION(int _X, int _Y) {
  22.             return (_X * _Y).ToString();
  23.         }
  24.         public void _PROCEDURE(int _X, int _Y) {
  25.             _Y *= _X;
  26.         }
  27.  
  28.     }
  29.     class Program
  30.     {        
  31.         static void Main(string[] args)
  32.         {
  33.             Console.Clear();
  34.  
  35.             _TEST _TESTER = new _TEST();
  36.  
  37.             string _STRING;
  38.  
  39.             _STRING = Versioned.CallByName(_TESTER, "_TESTSTR", CallType.Get).ToString();
  40.  
  41.             Console.WriteLine("Get _TESTSTR in _TEST : {0}",_STRING);
  42.  
  43.             Versioned.CallByName(_TESTER, "_TESTSTR", CallType.Set, "Changed By The CallByName");
  44.  
  45.             _STRING = Versioned.CallByName(_TESTER, "_TESTSTR", CallType.Get).ToString();
  46.  
  47.             Console.WriteLine("Set _TESTSTR in _TEST : {0}",_STRING);
  48.  
  49.             _STRING = (String)Versioned.CallByName(_TESTER, "_FUNCTION",CallType.Method, 2, 3);
  50.  
  51.             Console.WriteLine("Use _FUNCTION function in _TEST : {0}*{1}={2}",2,3,_STRING);
  52.  
  53.             int _A = 3, _B = 3;
  54.  
  55.             Versioned.CallByName(_TESTER, "_PROCEDURE", CallType.Method, _A, _B);
  56.  
  57.             Console.WriteLine("Use _PROCEDURE sub in _TEST {1}={0}*{1}",3,3,_A.ToString());
  58.  
  59.             Console.ReadLine();
  60.         }
  61.     }
  62. }
--------------------------------------------------------------------

Başak & Gökhan Tarhan

Software Development Specialists
Nov 26 '07 #1
0 8813

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Edlueze | last post by:
I use the CallByName function quite regularly, but the sub routines that I have always called have been located within the form code. The call I use looks something like this: Dim CallObjectForm...
12
by: Jelle van Baardewijk | last post by:
Does anybody know if there's way to do this in C#? Jelle van Baardewijk
2
by: MFRASER | last post by:
Is there any CallbyName function inside of C#. I need to shift my items in a collection Psuedo code aItem has hours 1-24 and I need to be able to shift the hours. foreach(MapItem aItem in...
1
by: Kishor | last post by:
Hi all, I am facing one problem with callbyName. I am facing one problem, instead of describing this I am pasting this code. I wanted to know is there any other way to avoid this error and make...
8
by: Rob R. Ainscough | last post by:
I use a generic Processing form (modal) where I pass it an object and method name and parameters if needed and then use CallbyName to execute the passed in method. What this does for me is lock...
0
by: Phill. W | last post by:
I have a Console application (which will wind up running on a remote host). This has two Threads - the main processor and a second that provides a socket-based way of "talking" to the first. ...
1
by: Fredrik Melin | last post by:
Hi, We had real bad problems with reports being printed wrong (active reports ..net 2.0), which we tracked down to being because before we printed the report we used CallByName to READ...
0
by: Tim | last post by:
If I use CallByName, and the function that is called contains runtime errors, I don't get the code to pause and debug at the point of the error, rather at the callbyname line. This makes...
1
by: Timberwoof | last post by:
For i = 1 To 3 CallByName(Form1.Controls("ComboBox" & i), "items.add", Type.Set, "1st item") CallByName(Form1.Controls("ComboBox" & i), "items.add", Type.Set, "2nd item")...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.