小编Ani*_*317的帖子

将字节从字节数组复制到 C# 中另一个字节数组的特定位置

我有两个字节数组 - array1 和 array2 。我的目标是根据每个数组的起始索引将字节从第一个数组复制到第二个数组,并用特定字节填充未填充的字节。

byte[] array1 = new byte[5]
The data is as follows: 11,22,00,33,44; 

byte[] array2 = new byte[10];     
Run Code Online (Sandbox Code Playgroud)

我需要将字节从 array1 复制到 array2。数据需要从 array2 中的位置 3 复制,并用值 ff 填充其余的空位置。即我在 array2 中的结果将是 {ff,ff,ff,11,22,00,33,44,ff,ff}

任何帮助将是可观的。

提前致谢!

c# arrays bytearray

3
推荐指数
1
解决办法
8926
查看次数

使用mvvm动态地在选项卡项中包含关闭按钮

我在MainWindow中有一个tabcontrol.tabcontrol的默认/第一个选项卡是主用户控件.在主页中,我有一个可以添加更多选项卡的按钮.

MainWindow.xaml:

<Window.Resources>
    <DataTemplate x:Key="ClosableTabItemTemplate"> 
        <Button Content="X" Cursor="Hand" DockPanel.Dock="Right" Focusable="False"
                FontFamily="Courier" FontSize="9" FontWeight="Bold"  Margin="0,1,0,0" Padding="0" 
                VerticalContentAlignment="Bottom" Width="16" Height="16"/>            
    </DataTemplate>
</Window.Resources>

<Grid>
    <TabControl Name="tabMain" ItemsSource="{Binding TabItems,UpdateSourceTrigger=PropertyChanged}" />   
</Grid>
Run Code Online (Sandbox Code Playgroud)

在我的视图模型中,我有添加功能,其中添加了新选项卡.我需要所有这些新添加的标签的关闭按钮.

public MainViewModel()
    {
        try
        {
            Home Item2 = new Home();                           
            TabItems.Add(new TabItem() { Header = "Home", Content = Item2 });                             
        }
        catch(Exception ex)
        {
            MessageBox.Show("Exception "+ex);
        }

//Function to add new tabs.
public void AddNewTabs()
{
            ChildWindow childContent = new ChildWindow();
            TabItem item = new TabItem() { Header = "New Tab", Content …
Run Code Online (Sandbox Code Playgroud)

c# wpf tabcontrol mvvm

3
推荐指数
2
解决办法
6203
查看次数

标签 统计

c# ×2

arrays ×1

bytearray ×1

mvvm ×1

tabcontrol ×1

wpf ×1