如何使用输入和输出参数调用功能

时间:2016-10-18 11:31:44

标签: c#

我试图调用一个具有输入和输出参数的函数。请参阅请求输入和输出参数的方法图像。

请任何人指导如何调用此方法并获得所需的输出。提前谢谢。

更新 我使用以下代码来调用该方法,但它给出了红线错误:

U2E.TranToEnglish(channel_inn, client_app_in, login_in, pwd_in, tp_trans_id_in, name_in, father_name_in, mother_name_in, address_1_in, address_2_in, birth_place_in, cnic_in, 
                  ref string i , ref string i1, ref string i2, ref string i3, ref string i4, ref string i5, ref string i6, ref string i7, ref string i8, ref string i9, ref string i10, ref string i11, ref string i12, ref string i13, ref string i14, ref string i15, ref string i16, ref string i17, ref string i18);

3 个答案:

答案 0 :(得分:0)

您有输入和参数。请参阅下面有关如何为方法提供ref参数的示例。

class Program
    {
        static void Main(string[] args)
        {
            string valueout="cat";
            SetString1(10, ref valueout);
        }
        static void SetString1(int value_IN,ref string value_OUT)
        {
            if (value_OUT == "cat") 
            {
                Console.WriteLine("Is cat");
            }
            value_OUT = "dog"; 
        }


    }

因此,对于每个ref参数,您应该声明变量并初始化该值并将其发送给方法。

答案 1 :(得分:0)

谢谢大家。

我完成了它并使用了以下代码。我也非常感谢谁立即回复了这个问题。以下是解决我的问题的代码。

            string a3_first_name = "";
            string b3_last_name = "";
            string c3_type = "";
            string d3_number = "";
            string e3_dt_b = "";
            string f3_nationality = "";
            string g3_appartment = "";
            string h3_street = "";
            string i3_block = "";
            string j3_city = "";
            string k3_area = "";
            string l3_postal_code = "";
            string m3_country = "";
            string n3_birth_place = "";
            string o3_Address_2 = "";
            string p3_father_name = "";
            string q3_mother_name = "";
            string r3_aksa_train_id = "";
            string s3_message = "";

            WebReference.Service MyService = new WebReference.Service();
            MyService.Converted("MNPO", "FARZ", "DFT", "BBN&&$TS", "1", "AaMER", "Father", "Mother", "Address1", "Address2", "City", "cccet", ref a3_first_name, ref b3_last_name, ref c3_type, ref d3_number, ref e3_dt_b, ref f3_nationality, ref g3_appartment, ref h3_street, ref i3_block, ref j3_city, ref k3_area, ref l3_postal_code, ref m3_country, ref n3_birth_place, ref o3_Address_2, ref p3_father_name, ref q3_mother_name, ref r3_aksa_train_id, ref s3_message); 

答案 2 :(得分:-2)

U2E.TranToEnglish(channel_inn, client_app_in, login_in, pwd_in, tp_trans_id_in, name_in, father_name_in, mother_name_in, address_1_in, address_2_in, birth_place_in, cnic_in, ref i , ref i1, ref i2, ref i3, ref i4, ref i5, ref i6, ref i7, ref i8, ref i9, ref i10, ref i11, ref i12, ref i13, ref i14, ref i15, ref i16, ref i17, ref i18)