KeyValuePair<bool, string>

以前在做数据库插入或者修改时  只能返回操作成功或者失败

如果要同时返回失败和失败异常记录 则只能返回一个model类 或者把两个参数用连接符拼起来 然后到bll层再去分隔

今天看到 KeyValuePair<bool, string>   很适合上面说的那种情况

 

ContractedBlock.gif ExpandedBlockStart.gif 代码
 
   
KeyValuePair < bool , string > loginResult;

if (result)
loginResult
= new KeyValuePair < bool , string > ( true , " 成功 " );
else
loginResult
= new KeyValuePair < bool , string > ( false , " 失败 " );

if (loginResult .Key)
{
Response.Write(loginResult.Value);
}

 

转载于:https://www.cnblogs.com/zaspx/archive/2010/09/03/1816782.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据提供的引用[1],可以使用以下步骤在WPF中读取折线的TXT文件并绘制曲线: 1. 在XAML文件中添加一个按钮、一个文本框和一个Chart控件。 ```XAML <Button Content="打开" Click="OpenFile_Click"/> <TextBox x:Name="FilePathTextBox"/> <chartingToolkit:Chart> <chartingToolkit:LineSeries Title="折线图" DependentValuePath="Value" IndependentValuePath="Key"/> </chartingToolkit:Chart> ``` 2. 在.cs文件中添加以下代码: ```C# private void OpenFile_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.DefaultExt = ".txt"; dlg.Filter = "Text documents (.txt)|*.txt"; Nullable<bool> result = dlg.ShowDialog(); if (result == true) { string filename = dlg.FileName; FilePathTextBox.Text = filename; // 读取文件内容 string[] lines = System.IO.File.ReadAllLines(filename); // 将文件内容转换为数据点 List<KeyValuePair<int, int>> valueList = new List<KeyValuePair<int, int>>(); for (int i = 0; i < lines.Length; i++) { string[] values = lines[i].Split(','); int x = int.Parse(values[0]); int y = int.Parse(values[1]); KeyValuePair<int, int> pair = new KeyValuePair<int, int>(x, y); valueList.Add(pair); } // 将数据点添加到折线图中 LineSeries lineSeries = (LineSeries)Chart.Series[0]; lineSeries.ItemsSource = valueList; } } ``` 3. 在.cs文件中添加以下命名空间: ```C# using System.Collections.Generic; using System.Windows.Controls.DataVisualization.Charting; ``` 4. 运行程序并单击“打开”按钮,选择要读取的TXT文件,然后单击“确定”按钮。程序将读取文件内容并将其转换为数据点,然后将数据点添加到折线图中。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值