这是代码:
string myVar = "00000";
string myPtrn = "(.).(...)";
string mySub = "$1" + "1" + "$2";
string myResult = Regex.Replace(myVar, myPtrn, mySub);
MessageBox.Show("Before :\t" + myVar + "\nAfter :\t" + myResult);
Run Code Online (Sandbox Code Playgroud)
结果是$11000.
我想01000来自00000.
但是,我猜,$1很困惑$11.
[编辑]
我想使用 DataTable 在 Datagridview 中使用图像。
RadioButton 只是本文的一个简单问题格式。
让我澄清一下这一点。
如何使用绑定样式在 datagridview 上添加这个“图像”或那个“图像”?
(因为,
我想,这比正常方式更快。我制作了500行图像和文字——都是16*16的短文字。如果我重画的话,就花了我 20秒。二十个!!!这是无稽之谈。我尝试过“双缓冲区”解决方法,但没有更好的方法。)
我做了代码。
它只是 DataGridView 上 RadioButton 的起点。
到目前为止,一切都很好。
我在上面制作了五幅图像。
像这样。
dataGridView1.RowCount = 5;
dataGridView1.Rows[0].Cells[0].Value = Properties.Resources.WhiteBall;
dataGridView1.Rows[1].Cells[0].Value = Properties.Resources.BlueBall;
dataGridView1.Rows[2].Cells[0].Value = Properties.Resources.WhiteBall;
dataGridView1.Rows[3].Cells[0].Value = Properties.Resources.WhiteBall;
dataGridView1.Rows[4].Cells[0].Value = Properties.Resources.WhiteBall;
Run Code Online (Sandbox Code Playgroud)
问题。
如何使用“DataTable 绑定样式”获得相同的结果?
我只有错误“行需要正确的数据类型”。
我第二次尝试的代码是;
DataTable myTable = new DataTable();
DataColumn myCoulmn = new DataColumn();
myCoulmn.DataType = Type.GetType("System.Drawing.Bitmap");
myTable.Columns.Add(myCoulmn);
DataRow myRow = myTable.NewRow();
myRow[0] = Properties.Resources.WhiteBall;
myRow[1] = Properties.Resources.BlueBall;
myRow[2] = Properties.Resources.WhiteBall;
myRow[3] = Properties.Resources.WhiteBall;
myRow[4] = …Run Code Online (Sandbox Code Playgroud) 我有一个给定的数据(我只是把它作为一个List在这里).
List<string> list1 = new List<string>();
foreach( var x in Regex.Split( "A B C D E F", " " ) )
list1.Add( x );
Run Code Online (Sandbox Code Playgroud)
现在我想做一个像这样的最终List.
List<string[]> list2 = new List<string[]>();
Run Code Online (Sandbox Code Playgroud)
所以,我试过这个代码(我试过LINQ但没有收获).
int i = 0;
string[] array1 = new string[2];
foreach( var x in list1 )
{
if( i % 2 == 0 )
{
array1[0] = x;
}
else
{
array1[1] = x;
list2.Add( array1 );
array1 = new string[2];
}
i++;
}
Run Code Online (Sandbox Code Playgroud)
我想使用LINQ获得相同的结果.请帮忙.
谢谢. …
我有以下代码(我是初学者);
string myVar = "abcd";
var myQuery = from x in myVar select x;
MessageBox.Show( string.Join("\n", myQuery));
Run Code Online (Sandbox Code Playgroud)
我希望得到这样的结果;
1 a
2 b
3 c
4 d
Run Code Online (Sandbox Code Playgroud)
请给我一些提示.
谢谢.
我用 OpenXML 制作了这个文档。. 我正在学习 OpenXML。哦。。太难了。
MainDocumentPart m = wd.AddMainDocumentPart();
m.Document = new Document();
Body b1 = new Body();
int myCount = 5;
for (int z = 1; z <= myCount; z++)
{
Paragraph p1 = new Paragraph();
Run r1 = new Run();
Text t1 = new Text(
"The Quick Brown Fox Jumps Over The Lazy Dog " + z );
r1.Append(t1);
p1.Append(r1);
b1.Append(p1);
}
m.Document.Append(b1);
Run Code Online (Sandbox Code Playgroud)
我想改变它的方向从纵向 - >横向并将其边距设置得更小。
加工前;
我可以用这样的 VBA 代码实现这个目标;
With ActiveDocument.PageSetup
.Orientation = wdOrientLandscape
.TopMargin …Run Code Online (Sandbox Code Playgroud) 例如; "控制台类""Acme.Collections.Stack类"
有人说,准确的术语应该是"阶级".当然,可以使用术语"类型",因为它是一般术语.
在我看来,"阶级"是不正确的."class"应仅用于user_defined类型.Consle,Stack不是自定义的,所以它应该是"类型".
MSDN这样说; 类是一种构造,使您可以通过将其他类型,方法和事件的变量组合在一起来创建自己的自定义类型.
有什么好建议吗?
以下代码按预期工作,但似乎不优雅.
.Where(x => x.Attributes().Contains(x.Attribute("Quick"))
&& !x.Attributes().Contains(x.Attribute("Brown"))
&& !x.Attributes().Contains(x.Attribute("Fox"))
&& !x.Attributes().Contains(x.Attribute("Jumps"))
&& !x.Attributes().Contains(x.Attribute("Lazy"))
&& !x.Attributes().Contains(x.Attribute("Dogs")))
Run Code Online (Sandbox Code Playgroud)
如你所见,我正在检查是否
[编辑]我的意图是......我想确保元素只有一个属性.我的意思是在这种情况下只有"快速"属性.我知道伯爵的风格,伯爵不区分它的名字.[/编辑]
[Edit2]我想要元素,只要它有sigle属性,没有别的.[/ Edit2]
[Edit3]"x"是一个例如..
<mySeg Quick="1" Brown="Two" Fox="None" Jumps="2016_En" Lazy="100" Dogs="Source"> // I do not want this XElement
Run Code Online (Sandbox Code Playgroud)
要么
<mySeg Quick="2" Brown="Ten"> // Nah.
Run Code Online (Sandbox Code Playgroud)
要么
<mySeg Quick="3"> // yes, this is one I'm looking for.
Run Code Online (Sandbox Code Playgroud)
[EDIT3]
[编辑4]我想,我必须使用这个.实际上,这是我在这篇文章之前使用的那个.我一眼就好了.
x.Attributes().Contains(x.Attribute("Quick")) && x.Attributes().Count() == 1 //thanks Ryan
Run Code Online (Sandbox Code Playgroud)
[Edit4]