我有以下VB.NET类定义:
<Serializable()> Partial Public Class Customers
End Class
Run Code Online (Sandbox Code Playgroud)
在另一个文件中我有相同的东西(当然有不同的方法和变量).当我编译时,我收到以下错误:
属性'SerializableAttribute'不能多次应用.
这个错误非常自我解释.我的问题是,如果我只将一个类标记为Serializable(),我可以假设整个类被标记为serializable()吗?换句话说,我只需要在类中的1个位置使用serializable()标记吗?
我正在尝试创建一个类似于节点图的树,就像这里的示例图像一样.我有以下代码:
private void DrawNode(Graphics g, Node<T> node, float xOffset, float yOffset)
{
if (node == null)
{
return;
}
Bitmap bmp = (from b in _nodeBitmaps where b.Node.Value.Equals(node.Value) select b.Bitmap).FirstOrDefault();
if (bmp != null)
{
g.DrawImage(bmp, xOffset, yOffset);
DrawNode(g, node.LeftNode, xOffset - 30 , yOffset + 20);
DrawNode(g, node.RightNode, xOffset + 30, yOffset + 20);
}
}
Run Code Online (Sandbox Code Playgroud)
我的代码几乎正常工作.我遇到的问题是一些节点重叠.在上图中,节点25和66重叠.我确定,原因是因为它在数学上将左节点和右节点放置在空间上,所以父节点的右节点与相邻父节点的左节点重叠.我该如何解决这个问题?
更新:
这是我在dtb的建议后做的代码更新:
int nodeWidth = 0;
int rightChildWidth = 0;
if (node.IsLeafNode)
{
nodeWidth = bmp.Width + 50; …Run Code Online (Sandbox Code Playgroud) 事实证明,这很简单,但我在Google上找不到任何关于此的内容.我有一个Winforms应用程序,它有一个文本框.当我按下TAB键时,光标跳到下一个控件.我想要的是将一个实际的标签(或4个空格)插入我的文本框中.我遗失了什么财产?
有人可以帮助我找出我需要在我的两个列表上全局更改列宽度的选择器吗?
使用它,当然会选择所有细胞:
table td {
width: 50px;
}
Run Code Online (Sandbox Code Playgroud)
我想要的是这个:
<table>
<tr>
<td style="width: 50px">data in first column</td>
<td style="width: 180px">data in second column</td>
</tr>
<tr>
<td style="width: 50px">more data in first column</td>
<td style="width: 180px">more data in second column</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
我想将宽度规范放在样式表中,而不是为每个标记隐式键入宽度.什么CSS选择器可以让我设置50px宽度和180px适当?
我正在尝试更新我的Mvc Web项目中的NuGet依赖项.我要去我的项目,右键单击它,然后去管理NuGet包.弹出NuGet包管理器,然后单击"更新",我要更新的特定包是"Microsoft ASP.NET Web Pages"和"jQuery".如果我单击其中任何一个,然后单击更新按钮,弹出更新窗口,然后几乎立即崩溃.然后Visual Studio将重新启动,当我打开我的项目时,没有任何更新.该错误是关于尝试写入受保护的内存的问题.
有没有人对可能造成这种情况有什么建议?我在Windows 7上运行Visual Studio 2013 Update 4.
更新
作为这个问题的后续内容,我只是想补充一些细节.我使用/ log标志运行Visual Studio,希望获得更多信息.这是文件中一些最后条目的转储:
<entry>
<record>749</record>
<time>2015/06/10 15:24:27.421</time>
<type>Information</type>
<source>VisualStudio</source>
<description>Entering function CVsPackageInfo::HrInstantiatePackage</description>
<guid>{77A5A151-6A9B-4D08-BC38-340AB29566E2}</guid>
</entry>
<entry>
<record>750</record>
<time>2015/06/10 15:24:27.421</time>
<type>Information</type>
<source>VisualStudio</source>
<description>Begin package load [CctSharedPackage]</description>
<guid>{77A5A151-6A9B-4D08-BC38-340AB29566E2}</guid>
</entry>
<entry>
<record>751</record>
<time>2015/06/10 15:24:27.514</time>
<type>Information</type>
<source>VisualStudio</source>
<description>End package load [CctSharedPackage]</description>
<guid>{77A5A151-6A9B-4D08-BC38-340AB29566E2}</guid>
</entry>
<entry>
<record>752</record>
<time>2015/06/10 15:24:29.748</time>
<type>Information</type>
<source>VisualStudio</source>
<description>Entering function CVsPackageInfo::HrInstantiatePackage</description>
<guid>{BC9CA0B3-BB4F-449A-967C-29A8FAE32086}</guid>
</entry>
<entry>
<record>753</record>
<time>2015/06/10 15:24:29.748</time>
<type>Information</type>
<source>VisualStudio</source>
<description>Begin package load [Microsoft VSDesigner WCF Package]</description>
<guid>{BC9CA0B3-BB4F-449A-967C-29A8FAE32086}</guid>
</entry>
<entry> …Run Code Online (Sandbox Code Playgroud) 我很好奇为什么TypeScript转换器将枚举编译成字典查找而不是简单对象.这是一个TypeScript枚举示例:
enum transactionTypesEnum {
None = 0,
OSI = 4,
RSP = 5,
VSP = 6,
SDIV = 7,
CDIV = 8
}
Run Code Online (Sandbox Code Playgroud)
这是JS代码TypeScript发出的:
var TransactionTypes;
(function (TransactionTypes) {
TransactionTypes[TransactionTypes["None"] = 0] = "None";
TransactionTypes[TransactionTypes["OSI"] = 4] = "OSI";
TransactionTypes[TransactionTypes["RSP"] = 5] = "RSP";
TransactionTypes[TransactionTypes["VSP"] = 6] = "VSP";
TransactionTypes[TransactionTypes["SDIV"] = 7] = "SDIV";
TransactionTypes[TransactionTypes["CDIV"] = 8] = "CDIV";
})(TransactionTypes || (TransactionTypes = {}));
Run Code Online (Sandbox Code Playgroud)
我的好奇心想知道为什么TypeScript不会简单地这样做:
var TransactionTypes = {
None: 0,
OSI: 4,
RSP: 5,
VSP: 6,
SDIV: 7,
CDIV: …Run Code Online (Sandbox Code Playgroud) 我在窗体上有一个带有Rich Textbox控件的Windows窗体.我想要做的是使每行只接受32个字符的文本.在32个字符之后,我希望文本流到下一行(我不想插入任何回车符).WordWrap属性几乎可以执行此操作,除了它将所有输入的文本移动到文本中的最后一个空格并将其全部移动.我只想在32个字符后整齐地包裹文本.我怎样才能做到这一点?我正在使用C#.
我想要做的是使用DrawString()方法将字符串绘制到位图.为此,我需要创建一个位图并从位图中获取Graphics对象,然后在该Graphics对象上调用DrawString().
问题是,我怎么知道,在我创建初始位图时,有多少像素宽和长来制作我的位图?
我知道这与MeasureString()有关,但是为了使用MeasureString(),我需要从位图中获取Graphics对象.在我创建位图之前我无法做到这一点,直到我知道尺寸才能做到这一点.这似乎是一个循环的悖论!
有人请帮我解决这个问题吗?
现在,我使用以下代码创建一个Shuffle扩展:
public static class SiteItemExtensions
{
public static void Shuffle<T>(this IList<T> list)
{
var rng = new Random();
int n = list.Count;
while (n > 1)
{
n--;
int k = rng.Next(n + 1);
T value = list[k];
list[k] = list[n];
list[n] = value;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我正在寻找一种更快,更有效的方法来做到这一点.现在,使用秒表类,大约需要20秒来洗牌100,000,000件物品.有没有人有任何想法让这更快?
c# ×7
winforms ×3
.net ×2
asp.net ×2
asp.net-mvc ×1
bitmap ×1
css ×1
drawstring ×1
enums ×1
gdi+ ×1
graphics ×1
html ×1
javascript ×1
nuget ×1
richtextbox ×1
textbox ×1
typescript ×1
vb.net ×1
word-wrap ×1