这是我的代码
private void buttonClickone(object sender, RoutedEventArgs e) {
if (WhichV == -1) {
ShowMessage(PleaseSelectXXX);
return;
}
ButtonClick(1);
BeginOPHandler(Ep, null);
}
Run Code Online (Sandbox Code Playgroud)
我这里的逻辑是,如果满足 if 语句的条件,我想取消选中切换按钮但不执行BeginOPHandler(Ep, null)操作。
我怎样才能做到这一点?
我有一个可以实现各种集合和数据类型的接口,它可以很好地处理某些集合,但字典给我带来了问题,我猜是因为字典有点不同并且有键值对?
public interface IStructure
{
void InsertRun<T> (T item);
ICollection RetrieveSortedListRun<T>();
T RetrieveItemRun<T>(T item);
}
class DictionaryRun : IStructure
{
IDictionary<int, object> dictionary;
public DictionaryRun()
{
dictionary = new Dictionary<int, object>();
}
public void InsertRun<T>(T item)
{
dictionary.Add(dictionary.Count + 1, item);
}
public ICollection RetrieveSortedListRun<T>()
{
return dictionary;
}
public T RetrieveItemRun<T>(T item)
{
return item;
}
}
Run Code Online (Sandbox Code Playgroud) 我做了一些逻辑,但它的错误?
我的代码
private static void DrawText(String text, Font font, Color textColor, Color backColor)
{
Image img = new Bitmap(640, 360);
Graphics drawing = Graphics.FromImage(img);
Color color = textColor;
if (text.Length <= 80) {
Rectangle displayRectangle =
new Rectangle(new Point(20, 100), new Size(img.Width - 1, img.Height - 1));
} else {
Rectangle displayRectangle =
new Rectangle(new Point(20, 80), new Size(img.Width - 1, img.Height - 1));
}
StringFormat format1 = new StringFormat(StringFormatFlags.NoClip);
StringFormat format2 = new StringFormat(format1);
// ERROR ON NEXT LINE …Run Code Online (Sandbox Code Playgroud) 当我在未初始化的变量中设置断点并运行项目时,我观察到在运行时调试器不会在该行停止而不是停止,它会触及未初始化变量的下一行.
我还观察到,在运行时断点也显示在下一行.
例:
string strTest; // Set breakpoint here.
Console.WriteLine("This is test"); // The debugger stops here, not in the line above.
strTest = "Hi I am Test"; // Initialize string variable here.
Run Code Online (Sandbox Code Playgroud)
这是预期的行为吗?我的意思是为什么VS调试器不会停止在未初始化的变量?以及为什么在运行时断点移动到下一行未初始化的变量?
我是Stack Overflow和新手程序员的新手.我正在尝试构建Visual Studio 2010 C#其他人的代码作为学习机会.我无法弄清楚为什么我在附加的存根代码底部的四个类(第50,59,67和75行)中得到以下三个错误(我从原始程序中删除了所有与错误无关的内容) ):
1. “c_basic_object” ? Method must have a return type 2. “:” ? ; expected 3. “(p_name)” Invalid token ')' in class, struct, or interface member declaration 4. “p_name” ? The type or namespace name 'p_name' could not be found (are you missing a using directive or an assembly reference?)
该代码几乎与Andrew Troelsen在第4章的Pro C#2005中的Employee和Manager类相同.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestStub
{
class Program
{
static void Main(string[] args)
{
String strTest1 = …Run Code Online (Sandbox Code Playgroud) 你好今天我练习了SQL语句.当我尝试从%like%中选择数据库时,它在我使用变量时以及当我不使用它时输出不同的值.
请参阅follorwing考虑名为POSTS的简单表,每个帖子都有CONTENT和HEADING
现在当我尝试从这个表中选择时
SELECT *
FROM Posts
WHERE Headline like '%'+'fun'+'%' OR Content like '%'+'fun'+'%'
Run Code Online (Sandbox Code Playgroud)
我得到以下输出:
但是,如果我尝试在搜索中选择使用变量:
DECLARE @test NVARCHAR = 'fun'
SELECT * FROM Posts
WHERE Headline like '%'+@test+'%' OR Content like '%'+@test+'%'
Run Code Online (Sandbox Code Playgroud)
我得到这个输出:
所以我想知道这个变量怎么会改变结果,理论上它必须具有相同的输出?
谁能帮助我找到最有效的方式来按字母顺序在给定的字符串中打印字符出现以及该字符?
我可以计算字符串中字符的出现,但不能按字母顺序对其进行排序。
string OutputString = string.Empty;
int count = 1;
char[] charArr = inputString.ToCharArray();
for (int i = 0; i < charArr.Length; i++) {
for (int j = i + 1; j < charArr.Length; j++) {
if (charArr[i] == charArr[j])
count++;
}
if (!OutputString.Contains(charArr[i]))
OutputString += charArr[i].ToString() + count.ToString();
count = 1;
}
OutputString = string.Concat(OutputString.OrderBy(c => c));
Run Code Online (Sandbox Code Playgroud)
假设输入字符串在 xgdgyd
输出应为:
d2g2x1y1.
Run Code Online (Sandbox Code Playgroud) 下面的代码产生一个错误,说我的输入字符串格式不正确.为什么?
private void button7_Click(object sender, EventArgs e)
{
string uriAddTagtoGroup =
string.Format("http://localhost:8000/Service/AddTagtoGroup/{group}/{tag}",
textBox6.Text, textBox7.Text);
//line above says input string was not in the correct format?
}
Run Code Online (Sandbox Code Playgroud) 我有一个复杂的LINQ到EF查询超时.在调试时我添加了一个Take(200)并没有超时.奇怪的是它只返回了127行!
换句话说,即使它没有改变结果Take,也要添加加速查询.有什么可能导致这种情况?
为了澄清,生成的SQL完全相同,只是将Take(200)EF添加TOP 200到SELECT.
我有2个数据表,每个数据表有300,000行(从带有OLEDB的2个excel工作表导入的数据表).
第一个数据表是'dtTosearch',第二个数据表是'sourceDt'.
这是2个表的示例:
我需要为'untagged'列(sourceDt)中的每一行找到'token'列(dtTosearch)中每一行的匹配项.匹配条件是:
香港专业教育学院添加了代码的相关部分,它工作正常,但不是我想要的方式,我想改善处理时间,看看linqQuery()函数中的foreach循环 - 如果你帮我替换那个循环我会很感激通过将我的查询扩展到条件号4,循环操作条件4,因为linq查询的结果按'token'长度按降序排序,因此它将退出并返回具有最大行长度的结果.
Private Sub startScanning()
Dim siteNum As Double
Dim categoryNum As Double
Dim stringToSearchin As String
For i = 0 To sourceDt.Rows.Count - 1
siteNum = sourceDt.Rows(i).Item(0)
categoryNum = sourceDt.Rows(i).Item(1)
stringToSearchin = sourceDt.Rows(i).Item(3)
Debug.WriteLine( linqQuery(siteNum, categoryNum, stringToSearchin) & " " &
stringToSearchin)
Next
End Sub
Private Function linqQuery(ByVal sitenum As Double, ByVal cat As Double,
ByVal …Run Code Online (Sandbox Code Playgroud) c# ×8
.net ×2
linq ×2
collections ×1
debugging ×1
dictionary ×1
generics ×1
icollection ×1
select ×1
sorting ×1
sql ×1
sql-server ×1
string ×1
vb.net ×1
winforms ×1
wpf ×1