Вывод одинакового текста в переменную - C#
Формулировка задачи:
Нужно что бы тот текст который одинаковый через запитую в переменных textBox1 и textBox3 выводился в textBox5.
Суть заключается в том что мы получаем например айди пользователей вконтакте через запитую и те которые совпадают выводятся в переменную.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using xNet.Text;
using xNet.Net;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
//1
public string GetFriends()
{
string SourcePage = "";
try
{
using (var request = new HttpRequest())
{
SourcePage = request.Get("https://api.vk.com/method/friends.get?user_id=" + textBox2.Text + "").ToString();
}
}
catch { }
return SourcePage;
}
//2
public string GetFriendss()
{
string SourcePage = "";
try
{
using (var request = new HttpRequest())
{
SourcePage = request.Get("https://api.vk.com/method/friends.get?user_id=" + textBox4.Text + "").ToString();
}
}
catch { }
return SourcePage;
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
//1
string s = Convert.ToString(GetFriends());
textBox1.Text = s;
//2
string z = Convert.ToString(GetFriendss());
textBox3.Text = z;
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
}
}Решение задачи: «Вывод одинакового текста в переменную»
textual
Листинг программы
textBox5.Text = string.Join(",", textBox1.Split(',').Intersect(textBox3.Split(',')));