我是使用Silverlight的xaml(用于MVVM APPROACH)的初学者.我读了几篇文章,对此一点感到困惑.如果有人能解释以下之间的区别,我将非常感激.
假设我的XAML是:
xmlns:viewmodel="clr-namespace:smallMVVM"
......
......
<UserControl.Resources>
<viewmodel:ViewModel x:Key="ViewModel"/>
<viewmodel:DatetimeToDateConverter x:Key="MyConverter"/>
</UserControl.Resources>
Run Code Online (Sandbox Code Playgroud)
现在有什么区别:
我的意思是在MainPage.cs中,如果我这样做"this.DataContext = new ViewModel();".如果我执行以下操作,请在MainPage.xaml中<Grid DataContext="{Binding Source={StaticResource ViewModel}}">.这两者有什么区别吗?
ItemsSource="{StaticResource customers}"在某些例子中我看到的地方.有什么ItemSource不同DataContext.虽然我可以在示例中(1)看到我在DataContext的Binding中有相同的内容(请参阅此内容:Source={StaticResource ViewModel}并将(2)其替换为customers).两者有何不同?
有时我也直接看到ItemsSource="{Binding Students}"里面没有StaticResource.它与StaticResource有何不同?
一些例子很简单Binding="{Binding Name}".
怎么样SelectedItem和SelectedValue不同?
有人可以用一个简单的小例子解释一下吗?在互联网搜索中,有一些典型的例子供初学者理解.
我很困惑,这两者之间有什么区别?
循环和电路,所以请尽可能通过图表确定。
我想到的是循环总是在无向图中电路总是有向图。如果我错了,请纠正我?
我使用silverlight ot实现xml的反序列化,如下所示:
String xmlString =
<attributes>
<value>1</value>
<showstatus>yes</showstatus>
<disableothers>
<disableother>
<disablevalue>1</disablevalue>
<todisable>skew</todisable>
<todisable>skew_side</todisable>
</disableother>
<disableother>
<disablevalue>0</disablevalue>
<todisable>automodel</todisable>
</disableother>
</disableothers>
</attributes>
Run Code Online (Sandbox Code Playgroud)
在我尝试实现这一目标的过程中,我觉得我在课堂上有一些东西.课程如下:
[XmlRoot(ElementName = "attributes")]
public class Attributes
{
[XmlElement("disableOthers")]
public List<DisableOthers> DisableOthers { get; set; }
}
[XmlRoot(ElementName = "disableOthers")]
public class DisableOthers
{
[XmlElement("disableOthers")]
public List<DisableOther> DisableOther { get; set; }
}
[XmlRoot(ElementName = "disableOther")]
public class DisableOther
{
[XmlElement("disablingitem")]
public int DisablingItem { get; set; }
[XmlElement("todisable")]
public int ToDisable { get; set; }
[XmlElement("disablevalue")]
public int DisableValue …Run Code Online (Sandbox Code Playgroud) 我正在做一个visual c ++应用程序并尝试将大小分配给缓冲区(该缓冲区进一步用于存储流的内容).如果声明缓冲的大小小于那么没有问题
const int size= 319000; //here there is no problem
Run Code Online (Sandbox Code Playgroud)
但是为了从流中访问我想要的一些数据,我需要声明这样大小的缓冲区 -
const int size=4348928;//this size cause the problem
char buffer[size+1];
HRESULT hr = pStream->Read(buffer, size, &cbRead );
Run Code Online (Sandbox Code Playgroud)
虽然代码的最后两行对我的问题没有任何作用,但它只是让你知道我正在用这个缓冲区的大小做什么.
但是,当我声明这个大小时,它什么也没做(我的意思是我的视觉应用程序功能如下:如果你单击一个文件,它会生成一个流,我将该流存储在缓冲区中 - 如果我声明大小为319000的顺序程序运行正常,当大小增加到4348928它甚至不工作 - 当然没有错误)
我是 c# silverlight-5 初学者,我有一个场景,其中我使用了这样的类节点(它作为结构)
public class Node
{
public Node next, left, right;
public int symbol; // This variable will create problem
public int freq;
}public Node front, rear;
Run Code Online (Sandbox Code Playgroud)
这个类 Node 位于另一个类中,class Huffman就像这样
Class Huffman
{
public class Node
{
public Node next, left, right;
public int symbol; // This variable will create problem
public int freq;
}public Node front, rear;
}
Run Code Online (Sandbox Code Playgroud)
现在我接下来要做的是在 huffman 的构造函数中,我在运行时通过来自另一个类的构造函数调用接收变量“processingValue”的数据类型。因此,processingValue 的数据类型是在运行时由另一个类对 Huffman 的构造函数调用决定的。
在霍夫曼构造函数内部我必须做这样的事情:
Class Huffman
{
public class Node
{ …Run Code Online (Sandbox Code Playgroud) 我已经压缩了一个binary file使用Huffman encoding. 现在我试图找到compression efficiency.
在我的二进制文件中,我有符号(0 和 1 的一堆)和频率(符号的重复)。假设我有:
symbol :0 freq : 173
symbol :1 freq : 50
symbol :2 freq : 48
symbol :3 freq : 45
Run Code Online (Sandbox Code Playgroud)
文件大小为 (173+50+48+45)*8= 2528(如果我计算大小的方式正确?如果我错了,请纠正我。(在调试时我得到 2536)(还有 8 个我不知道知道为什么 ?)
压缩后我得到encoding这样的
symbol : 0 Code : 1
symbol : 1 Code : 00
symbol : 2 Code : 011
symbol : 3 Code : 010
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我如何使用这些信息获得这个二进制文件的霍夫曼压缩效率吗?(我尝试在谷歌上搜索,但没有二进制文件的样本,它们有一些浮点类型的频率,我无法理解如何将它们与我的二进制文件相关联)。非常感谢。这样做的算法(c/c++/c#)也很受欢迎。
如何使用当前 case 语句的值跳转到 switch-case 条件中的另一个 case 语句?
是否可以使用 switch case 来实现这种事情,还是有另一种方法来实现它?
有可能实现吗?如果没有,那么还有其他方法可以实现吗?
我正在尝试计算二进制文件中符号的频率c#,我已经在c ++中完成了,并且工作正常,我已经从c ++切换到c#因为我必须在c#中实现相同的.
注意:我不必使用LUT/Arrays只能使用链表.
通过frequency我的意思是符号的重复,并以数字symbols我的意思是如果我们看到使用的二进制文件xxd -b BinaryFile.bin,然后我们会得到很多8 bits的组合0和1.那么每个符号重复的次数是它的频率.
现在,我是如何尝试这样做的:
我c#通过mono filename.exe BinaryFile.bin在终端上用notepad ++中的文件名编写代码来实现它.
逻辑: 我读取BinaryFile中的每个符号,如果没有重复,那么我将它添加到链表的尾部,如果它重复,那么我增加它的频率.我重复完整的二进制文件.
码:
代码为c#(完整):(哪些不能正常工作,我已经指出问题包含代码的一部分,我把完整的代码,因为可能你需要它):
////Problem containing part starts here ////////
public Huffman(string[] args) //called from MyClass
{
Node tree = null;
int counter = 0;
using(var stream = new BinaryReader(System.IO.File.OpenRead(args[0])))
{
while (stream.BaseStream.Position < stream.BaseStream.Length)
{
int processingValue = stream.ReadByte();
Node ppt, pt, temp;
bool is_there = false; …Run Code Online (Sandbox Code Playgroud) 我正在研究 c# 并且是初学者。我在创建霍夫曼树的情况下,我计算二进制文件中符号的频率(我的意思是符号重复的次数是频率)。我试图使这个“符号”适用于所有数据类型像int,short,ulong等等。我这样做使用泛型。
然后我尝试运行我收到 4 个错误的代码,例如:
CS0246: The type or namespace name `T' could not be found. Are you missing a using directive or an assembly reference?
Run Code Online (Sandbox Code Playgroud)
我知道编译器无法识别这个“ T”,但在“ T”之前我只是使用public class Node<K>而不是public class Node<T> where T : K这样,那时错误是:
z.cs(13,23): warning CS0693: Type parameter `K' has the same name as the type parameter from outer type `shekhar_final_version_Csharp.Huffman<K>'
z.cs(10,18): (Location of the symbol related to previous warning)
Run Code Online (Sandbox Code Playgroud)
所以我不得不K用等效的“ …
我是VS 2012 silverlight-5初学者.我试图从xml文件序列化和反序列化.这样做时我有以下错误:
The type or namespace name 'Serializable' does not exist in the namespace 'System' (are you missing an assembly reference?)
The type or namespace name 'SerializableAttribute' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'DatamemberAttribute' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'Datamember' could not be found (are you missing a using directive or an …Run Code Online (Sandbox Code Playgroud) c# ×8
.net ×2
algorithm ×2
c++ ×2
silverlight ×2
xml ×2
binaryfiles ×1
buffer ×1
casting ×1
compression ×1
constructor ×1
cycle ×1
generics ×1
graph-theory ×1
huffman-code ×1
linked-list ×1
mvvm ×1
types ×1
xaml ×1