我怎样才能使用委托 [英] How can I use delegate
本文介绍了我怎样才能使用委托的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
PLS。我的应用程序中需要一些帮助吗?
Pls. I need some help here this code in my app?
string[] s = { "Phone Number1" ,"Phone Number2"};
WhatSocket.Instance.SendSync(s);
//Declare Delegate Event
WhatSocket.Instance.OnGetSyncResult += Instance_OnGetSyncResult;
//Delegate Event
void Instance_OnGetSyncResult(int index, string sid, Dictionary<string, string> existingUsers, string[] failedNumbers)
{
foreach (KeyValuePair<string, string> iteam in existingUsers)
{
MessageBox.Show("existing" + iteam.Key + iteam.Value);
}
foreach (string item in failedNumbers)
{
MessageBox.Show("not existing" + item);
};
}
此代码如何检查电话号码,如果在whatsapp注册,我已连接到whatsapp并发送一个消息在C#。
但是在发送消息之前我需要确定这个号码是否有whatsapp。?
我是新来的C#并委托
任何帮助请
This code for how to check a phone number if register at whatsapp or not I had connect to whatsapp and send a msg. in C#.
But I need to be in sure this number has whatsapp or not before send the msg.?
I'm new in C# and delegate
any help PLEASE
推荐答案
我认为你在这里很幸运,看来你获得代码的那个博客的作者发布了一个.NET项目...我认为这是他的代码使用WhatsApp进行演示。
在此页面上,您可以找到项目的链接:[ ^ ]。
请注意,从未知来源下载任何代码都可能危险,但如果这是一个真正的.NET解决方案,你应该能够打开源并研究它。
I think you are in luck here, it appears the author of that blog where you got the code has posted a .NET project ... I assume it's his code demonstrating using WhatsApp.
On this page you'll find the link to the project: [^].
Be aware that downloading any code from an unknown source is potentially dangerous, but if this is a real .NET solution, you should be able to open the source and study it.
请参考以下代码。
Please refer the following code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ExampleDelegates
{
class Program
{
public delegate void ShowDelegate(string Name);
static void Main(string[] args)
{
ShowDelegate DelegateObject = new ShowDelegate(ShowMethod);
DelegateObject.Invoke("This is me.");
Console.ReadLine();
}
public static void ShowMethod(string _Name)
{
Console.WriteLine(_Name);
}
}
}
如果你想使用委托创建公共委托的任何位置,并将该函数与委托匹配,并分配方法并调用方法。
If you want to use the delegate any where you create the public delegate and match the function with delegate and assign the method and invoke the method.
这篇关于我怎样才能使用委托的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文