我正在研究silverligth5(我以前的经验是c ++),我必须创建一个动态数组,其大小是动态决定的.
直到我拥有一切静态,它是这样的:
string[] position = new string[20]; //it must be dynamic I don't want to fix it to 20
for (int i = 0; i < pv.Root.Parameter.Count; i++)
{
if (name == pv.Root.Parameter[i].Name)
{
position[i] = name;
}
}
Run Code Online (Sandbox Code Playgroud)
可以看出,我的方式20只有尺寸,我希望它只有相同的长度 pv.Root.Parameter.Count.
怎么做到这一点?
编辑/当我尝试通过列表实现它时的问题:我在这一行有问题:
if (pv.Root.Parameter[loopCount].Name == position[loopCount])
{
rowGrid.Opacity=0.3;
}
Run Code Online (Sandbox Code Playgroud)
因为它肯定不会起作用,position[loopCount]因为position是List而且不能像这样索引.如何索引呢?
我正在尝试使用链表来增强我的指针概念.
我已经成功创建了链表,它也给出了最少的两个元素,但我尝试了一些元素来测试它.
突然间我发现它不能用于以下例子:
enter the size of node
4
start entering the number of elements until your size
6
1
7
59
Printing linked list
6-> 1-> 7-> 59->
The two minimumnumbers are min1 :1 and min2 : 1
Run Code Online (Sandbox Code Playgroud)
我这样做的完整代码是:你可以直接切换到函数find_two_min()
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
struct node
{
int freq;
struct node * next;
};
typedef struct node node;
node * tree;
//Problem creating area is below (code for finding minimum two elements)
void find_two_min(node**List,node** lmin1,node** …Run Code Online (Sandbox Code Playgroud) 我切换到c#并希望使用c#中的Console.Writeline()函数在一行中写入两个变量值.
在c ++中,我可以这样做:
cout<<"symbol : "<<symbol<<"frequency : "<<frequency<<endl;
Run Code Online (Sandbox Code Playgroud)
将打印:
symbol : a frequency : 10
Run Code Online (Sandbox Code Playgroud)
我尝试在c#中做,但它只打印第一个变量,我这样做:
Console.WriteLine("Symbol : " +parentNode.symbol ,"frequency is : " + code );
Run Code Online (Sandbox Code Playgroud)
只打印symbol : 10 不打印频率.
我尝试了两个Console.WriteLine()但是改变了这一行.
有什么帮助怎么实现呢?
我在程序上做这部分.我想将此堆栈面板上的UIElelemnts(radiobuttons)设置为部分可见,因此我想要任何可以使stackpanel属性IsEnabled设置为False的任何等效属性(任何quivalent属性或任何其他方式来实现此目的,因为stackpanel不支持IsEnabled ).
或者,如果有可能有另一个可能是stackpanel的父级并且还支持IsEnabled属性的conntainer.(当我在stackpanel上设置它们时,请不要建议为循环中的每个单选按钮设置IsEnabled为false因为我不能这样做,因为代码中的当前情况我想要一些可以设置为IsEnabled的大容器).
c# ×3
.net ×2
silverlight ×2
algorithm ×1
c ×1
c++ ×1
linked-list ×1
radio-button ×1
stackpanel ×1