Connecting Tech Pros Worldwide Help | Site Map
Reply
 
LinkBack Thread Tools Search this Thread
  #1  
Old November 26th, 2007, 02:16 PM
Newbie
 
Join Date: Nov 2007
Posts: 1
Default 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

Last edited by RedSon; December 18th, 2007 at 05:09 PM. Reason: [CODE] tags
Reply



Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.