重置按钮的C#代码 [英] C# code for reset button

查看:675
本文介绍了重置按钮的C#代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我的屏幕上有重置按钮.用户可以在屏幕上选择参数.如果他想返回到默认设置,则将按重置.请给我提供reset

Hi,
I have reset button in my screen.The user can select the parameters in the screen.If he wants to come back to the default settings he will press the reset.Please give me the syntax for reset

推荐答案

将参数对象深层复制到备份对象,并在按下重置按钮时将其还原.

Deep copy your parameters object to a backup object and restore the when you press the reset button.

public static T DeepCopy<t>(T obj)
{
 using (var ms = new MemoryStream())
 {
   var formatter = new BinaryFormatter();
   formatter.Serialize(ms, obj);
   ms.Position = 0;

   return (T) formatter.Deserialize(ms);
 }
}</t>


这篇关于重置按钮的C#代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆