zoukankan      html  css  js  c++  java
  • winform调用WCF默认实例

    一:截图

    二:调用代码

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace WCFwinformTest
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                comboBox1.SelectedIndex = 0;
            }
    
            #region 方法一
                private void button1_Click(object sender, EventArgs e)
                {
                    if (textBox1.Text.Trim().Length > 0)
                    {
                        WinformServiceReference.Service1Client winformSC = new WinformServiceReference.Service1Client();
                        int i = Convert.ToInt32(textBox1.Text.Trim());
                        MessageBox.Show(winformSC.GetData(i));
                    }
                } 
            #endregion
    
            #region 方法二
                private void button2_Click(object sender, EventArgs e)
                {
                    if (textBox2.Text.Trim().Length > 0)
                    {
                        WinformServiceReference.Service1Client WinformSC = new WinformServiceReference.Service1Client();
    
                        WinformServiceReference.CompositeType ct = new WinformServiceReference.CompositeType();
                        ct.BoolValue = Convert.ToBoolean(comboBox1.Text);
                        ct.StringValue = textBox2.Text;
    
                        WinformServiceReference.CompositeType newCT = new WinformServiceReference.CompositeType();
                        newCT = WinformSC.GetDataUsingDataContract(ct);
    
                        MessageBox.Show(newCT.StringValue);
                    }
                } 
            #endregion
        }
    }
  • 相关阅读:
    systemctl
    防火墙firewalld
    k8s 基础概念
    进程
    模板问题
    自动发现
    oracle操作
    aix 10代oracle zabbix2.4.4 日志监控
    paramiko
    test
  • 原文地址:https://www.cnblogs.com/hongmaju/p/4273911.html
Copyright © 2011-2022 走看看