Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- using System.Threading;
- namespace Example
- {
- public class YourClass
- {
- public int Some1 { get; set; }
- public int Some2 { get; set; }
- }
- public interface IIntefacee
- {
- public void AddYourClass(YourClass yourClass);
- public YourClass[] GetYourClassArray();
- }
- public class MyDataManager : IIntefacee
- {
- public void AddYourClass(YourClass yourClass)
- {
- //Здесь добавляем в бд
- }
- public YourClass[] GetYourClassArray()
- {
- //Здесь берем данные из бд
- return new YourClass[0]; //Сделал заглушку
- }
- }
- public class Form1
- {
- private IIntefacee DataManager;
- public Form1(IIntefacee DataManager)
- {
- this.DataManager = DataManager;
- }
- private void Button1_click()
- {
- var variable = DataManager.GetYourClassArray();
- //Делаем что-то с данными из бд
- }
- private void Button2_click()
- {
- var variable = new YourClass();
- DataManager.AddYourClass(variable);
- //Добавили в бд
- }
- }
- class Program
- {
- static void Main()
- {
- MyDataManager myDataManager = new MyDataManager();
- Form1 form = new Form1(myDataManager);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement