当我尝试打开我的应用程序配置文件时
ConfigurationManager.OpenExeConfiguration(filePath);
Run Code Online (Sandbox Code Playgroud)
它返回一个异常,因为没有文件.但在这种情况下我需要创建此文件.但据我所知,配置文件是通过在VS中添加如何:将应用程序配置文件添加到C#项目来创建的
那么,如何以其他方式创建此文件?
找不到将double转换为字符串的简单方法.我需要转换大数而不失真.如:
double d = 11111111111111111111;
string s = d.ToString();
Console.WriteLine(s);
//1.11111111111111E+19
Run Code Online (Sandbox Code Playgroud)
如何从double值获取与用户输入完全相同的字符串值.
11111111111111111111111 => "11111111111111111111111"
1.111111111111111111111 => "1.111111111111111111111"
有什么想法可以做到吗?
如何从solr/data/index一些简单的控制台Java应用程序读取数据?我找到了一些解决方案.
但也许有更简单的方法.请帮忙,我真的不知道该怎么办.
我需要通过后面的代码找到位于组合框附近的数据网格控件.发件人是一个ComboBox.
XAML代码:
<Window.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVis" />
<Style TargetType="{x:Type ComboBox}" x:Key="ComboboxSpreadsheetStyle">
<Setter Property="SelectedIndex" Value="0"/>
<EventSetter Event="SelectionChanged" Handler="Combobox_SelectionChanged"/>
</Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<ComboBox Grid.Row="0" Style="{StaticResource ComboboxSpreadsheetStyle}">
<ComboBoxItem x:Name="it1">Item1</ComboBoxItem>
<ComboBoxItem x:Name="it2">Item2</ComboBoxItem>
</ComboBox>
<DataGrid Background="Blue" Grid.Row="1" Visibility="{Binding ElementName=it1, Path=IsSelected, Converter={StaticResource BoolToVis}}">
<DataGrid.Columns>
<DataGridTextColumn>
<DataGridTextColumn.Header >
<TextBlock Text="Text1"/>
</DataGridTextColumn.Header>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
<DataGrid Background="Red" Grid.Row="1" Visibility="{Binding ElementName=it2, Path=IsSelected, Converter={StaticResource BoolToVis}}">
<DataGrid.Columns>
<DataGridTextColumn>
<DataGridTextColumn.Header >
<TextBlock Text="Text2"/>
</DataGridTextColumn.Header>
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
Run Code Online (Sandbox Code Playgroud)
CS代码:
private void Combobox_SelectionChanged(object sender, RoutedEventArgs e)
{
//find …Run Code Online (Sandbox Code Playgroud) 我有一个清单:
List<Tuple<int, int>> MyList = new List<Tuple<int, int>>();
Run Code Online (Sandbox Code Playgroud)
列表的值如下:
int int
0 2
0 1
0 4
1 2
1 3
1 0
2 0
2 9
2 1
3 2
3 5
3 2
Run Code Online (Sandbox Code Playgroud)
如何list按的最高值排序Item2但保存的顺序Item1?如下所示:
int int
2 0
2 9*
2 1
3 2
3 5*
3 2
0 2
0 1
0 4*
1 2
1 3*
1 0
Run Code Online (Sandbox Code Playgroud)
尝试使用MyList.OrderBy(x => x.Item2)但没有成功
我有一个带Combobox的DataGrid
<DataGridComboBoxColumn Header="Header 2" ItemsSource="{Binding Pet}">
Run Code Online (Sandbox Code Playgroud)
基于MVVM模式的项目.当我尝试在TextColumn上显示数据时,它可以工作
<DataGridTextColumn Header="Header 1" Binding="{Binding ID}" />
Run Code Online (Sandbox Code Playgroud)
但是,我不知道,如何绑定DataGridComboBoxColumn的数据.
型号代码:
public string ID
{
get { return _id; }
set { _id = value; NotifyPropertyChanged("ID"); }
}
public string[] Pet
{
get { return _pet; }
set { _pet = value; NotifyPropertyChanged("Pet"); }
}
Run Code Online (Sandbox Code Playgroud) 输出应该是一个大文本文件,其中每行的格式为Number.String,文本是随机的:
347. Bus
20175. Yes Yes
15. The same
2. Hello world
178. Tree
Run Code Online (Sandbox Code Playgroud)
必须以字节为单位指定文件大小.对以最快的方式生成大约1000MB以上的文件感兴趣.
我的代码用于生成随机文本:
public string[] GetRandomTextWithIndexes(int size)
{
var result = new string[size];
var sw = Stopwatch.StartNew();
var indexes = Enumerable.Range(0, size).AsParallel().OrderBy(g => GenerateRandomNumber(0, 5)).ToList();
sw.Stop();
Console.WriteLine("Queue fill: " + sw.Elapsed);
sw = Stopwatch.StartNew();
Parallel.For(0, size, i =>
{
var text = GetRandomText(GenerateRandomNumber(1, 20));
result[i] = $"{indexes[i]}. {text}";
});
sw.Stop();
Console.WriteLine("Text fill: " + sw.Elapsed);
return result;
}
public string GetRandomText(int size)
{
var builder = new …Run Code Online (Sandbox Code Playgroud)