在应用程序启动期间检索变量值 [英] Retrieving a variable value during application startup

查看:83
本文介绍了在应用程序启动期间检索变量值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在单击按钮时保存一个变量值,还需要在应用程序启动时检索该变量值.我知道可以通过使用数据库或文件轻松地完成此操作.但是我不想仅使用这些变量进行保存可变值.有什么办法吗?

 私有 无效 buttonSave_Click(对象发​​件人,RoutedEventArgs e)
{
    字符串生日;
    如果(autoCompleteBox1.Text == " )
    {
        MessageBox.Show(" );
    }
    其他 如果(!validateInput(autoCompleteBox1.Text, @"  ^ [0-9] \ d {1}/[0-9] \ d {1}/\ d {4} $"" ))
        autoCompleteBox1.Focus();
    其他
    {
        MessageBoxResult result = MessageBox.Show("  确认",MessageBoxButton.OK);

        生日= autoCompleteBox1.Text;
        pickBirthday = Birthday.Substring( 0  5 ); // 我需要保存此值
    }
}


单击保存按钮后,pickBirthday的值将被保存.但是当我重新运行程序时,我需要显示此保存的值.但是当前该值是null ..如何不使用数据库或文件来解决这个问题? div class ="h2_lin">解决方案

", 生日格式不不对!请遵循dd/mm/yyyy格式.")) autoCompleteBox1.Focus(); 其他 { MessageBoxResult result = MessageBox.Show(" 确认",MessageBoxButton.OK); 生日= autoCompleteBox1.Text; pickBirthday = Birthday.Substring( 0 5 ); // 我需要保存此值 } }


单击保存按钮后,pickBirthday的值将被保存.但是当我重新运行程序时,我需要显示此保存的值.但是当前该值是null ..如何不使用数据库或文件来解决这个问题? /blockquote>

将此信息保存在文件中是什么问题?

另一种选择是将其存储在注册表中的某个位置. (个人而言,我不会这样做,而是将xml文件用作数据存储).


我个人不使用Silverlight,但是在.Net中,当我们使用想要保留一些数据而没有完整的数据库来存储它.我做了 ^ ]在Silverlight设置上发现了 ^ ]看起来可能会对您有所帮助.希望对您有所帮助.


I need to save a variable value at button click and also need to retrieve that during application startup.I know this can be done easily by using database or using files.But i don''t want to use those for saving just a variable value.Are there any way to do this?

private void buttonSave_Click(object sender, RoutedEventArgs e)
{
    string birthday;
    if (autoCompleteBox1.Text == "")
    {
        MessageBox.Show("You don't give your birthday!");
    }
    else if (!validateInput(autoCompleteBox1.Text, @"^[0-9]\d{1}/[0-9]\d{1}/\d{4}$", "Birthday format isn't correct! Follow dd/mm/yyyy format.."))
        autoCompleteBox1.Focus();
    else
    {
        MessageBoxResult result= MessageBox.Show("Your Birthday Saved Successfully","Confirmation",MessageBoxButton.OK);

        birthday = autoCompleteBox1.Text;
        pickBirthday = birthday.Substring(0,5);//I need to save this value
    }
}


After clicking Save button the value of pickBirthday is saved.But when i re-run my program i need to show this saved value.But currently at that time the value is null..how can i fix this without using database or file?

解决方案

", "Birthday format isn't correct! Follow dd/mm/yyyy format..")) autoCompleteBox1.Focus(); else { MessageBoxResult result= MessageBox.Show("Your Birthday Saved Successfully","Confirmation",MessageBoxButton.OK); birthday = autoCompleteBox1.Text; pickBirthday = birthday.Substring(0,5);//I need to save this value } }


After clicking Save button the value of pickBirthday is saved.But when i re-run my program i need to show this saved value.But currently at that time the value is null..how can i fix this without using database or file?


What is the problem saving this information in a file?

Another option would be store somewhere in registry. (Personally, I wouldn''t do that and use a xml file as a datastore).


I personally don''t work with silverlight, but in .Net we use setting when we want to keep some data without a full database to store it. I did a google search[^] on silverlight settings and found this article[^] which looks like it might help you out. Hope it helps.


这篇关于在应用程序启动期间检索变量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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