我有多年在微软开发堆栈上开发的经验,主要是 Visual Studio 2012/c#。但是现在,我需要在 linux 上开发应用程序。虽然我知道 C++,但我已经好几年没真正接触到它了。我有几个问题。
关于我正在做什么的一些信息。我的项目是关于网络渠道分析。客户端很可能是没有 ui 的廉价工业 linux 盒子。我使用mono/c#来开发客户端。服务器将是使用 vs2012 c# 的 windows 开发。很可能使用 wpf 作为 ui。我计划在 linux(客户端)和 windows(服务器)之间共享网络/通信库。我使用 linux 的主要关注点是节省成本,因为客户端几乎是千台。
谢谢你。
在我的课堂上,我有一个私有方法Log().当我想使用log(在同一个类中)时,我输入'Log'然后当我输入'('时,它会自动编码完成代码的其他内容.我尝试使用visual studio intellisense而不是resharper但这个错误的代码完成仍然发生.我是否必须卸载resharper或者我还能做什么?
谢谢.
我想使用Parallel.invoke.如果我分配20个并行任务,则只有8个并发运行.我的CPU是http://ark.intel.com/products/47925,并且报告的线程数是8.我假设可以并行运行的任务数与线程的cpu数有关.我不想创建比线程数更多的任务.我怎么知道c#中的线程数?我尝试查询ParallelOptions.MaxDegreeOfParallelism,我得到的只是-1.
我想在 Android Studio 中调试 c++ 模块。我在 android studio 中创建了一个支持 c++ 的项目。
“启动 LLDB 服务器”永远不会停止。如果我停止调试,它仍然存在。如果我退出 android studio,我会收到有关正在运行后台进程的警告。我已经在 SDK 管理器中安装了 LLDB。我在我的设备中启用了调试。
我该怎么办?
我想将可用串行端口的列表绑定到ComboBox.目前,我手动添加可用的串口.像这样,
foreach (string s in SerialPort.GetPortNames())
{
ComboBoxItem cbi = new ComboBoxItem();
cbi.Content = s;
myComboBox.Items.Add(cbi);
}
Run Code Online (Sandbox Code Playgroud)
myComboBox是我的组合框名称.我该怎么做绑定?谢谢.
我想使用此链接https://github.com/praeclarum/sqlite-net提供的sqlite-net .
不幸的是,入门文档是不够的.它甚至没有提到如何创建数据库.我试着查看这些示例,遗憾的是,示例已被破坏(无法编译,运行时错误等).
我可以在网上找到的最实用的教程是http://blog.tigrangasparian.com/2012/02/09/getting-started-with-sqlite-in-c-part-one/
不幸的是,sqlite-net并不完全支持sqlite.org sqlite实现,因此使教程对praeclarum sqlite-net无用.
在教程中但在praeclarum sqlite-net中执行相同操作的等效方法是什么?
从教程
创建数据库(这是我卡住的地方)
SQLiteConnection.CreateFile("MyDatabase.sqlite");
Run Code Online (Sandbox Code Playgroud)
连接数据库
SQLiteConnection m_dbConnection;
m_dbConnection = new SQLiteConnection("Data Source=MyDatabase.sqlite;Version=3;");
m_dbConnection.Open();
Run Code Online (Sandbox Code Playgroud)
创建表格
string sql = "create table highscores (name varchar(20), score int)";
SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
command.ExecuteNonQuery();
Run Code Online (Sandbox Code Playgroud)
填表
string sql = "insert into highscores (name, score) values ('Me', 3000)";
SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
command.ExecuteNonQuery();
sql = "insert into highscores (name, score) values ('Myself', 6000)";
command = new SQLiteCommand(sql, m_dbConnection);
command.ExecuteNonQuery();
sql = "insert …Run Code Online (Sandbox Code Playgroud) 我运行多线程操作,每个操作都会向我的日志文件附加一些信息.问题是,有时日志文件被锁定以进行编辑,同时被其他线程访问,这会引发异常.如何确保日志写得正确?
这是片段
try
{
File.AppendAllText(fileName, appendString);
}
catch (System.Exception )
{
}
Run Code Online (Sandbox Code Playgroud)
现在,我只是忽略了这个例外.这导致一些日志没有被写入.
我有 4 条线段,A、B、C 和 D。每条线都表示为两个点。例如。线A由点A1和点A2表示。
我想要的是
测试相交时,线 A 射线不应
我该怎么做呢?
这就是我的问题的答案。
如何在 C# 中列出绑定/使用的 TCP 端口。使用jro的修改代码
static void ListUsedTCPPort(ref ArrayList usedPort)
{
IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties();
IPEndPoint[] tcpConnInfoArray = ipGlobalProperties.GetActiveTcpListeners();
IEnumerator myEnum = tcpConnInfoArray.GetEnumerator();
while (myEnum.MoveNext())
{
IPEndPoint TCPInfo = (IPEndPoint)myEnum.Current;
usedPort.Add(TCPInfo.Port);
}
}
Run Code Online (Sandbox Code Playgroud)
原始问题。 这就是我使用 C# 列出 TCP 端口的方式。这是我在这个论坛中找到的修改后的代码(忘记了我到底是从哪里得到的。如果您是原始开发人员,请通知我,并在适当的时候注明积分。)
//List used tcp port
static void ListUsedTCPPort(ref ArrayList usedPort)
{
IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties();
TcpConnectionInformation[] tcpConnInfoArray = ipGlobalProperties.GetActiveTcpConnections();
IEnumerator myEnum = tcpConnInfoArray.GetEnumerator();
while (myEnum.MoveNext())
{
TcpConnectionInformation TCPInfo = (TcpConnectionInformation)myEnum.Current;
usedPort.Add(TCPInfo.LocalEndPoint.Port);
}
}
Run Code Online (Sandbox Code Playgroud)
问题是,结果与 TCPview(协议-TCP,本地端口)中列出的使用的 tcp 端口不同。顺便说一句,我确实知道这个列表在调用的确切时间使用了 TCP 端口。我做错了什么?
我有一个方法,可以创建一个调用控制台应用程序的进程.
double myProcess()
{
double results;
Process process = new Process();
process.EnableRaisingEvents = true;
process.OutputDataReceived += new DataReceivedEventHandler(process_OutputDataReceived);
process.StartInfo.FileName = filename;
process.StartInfo.Arguments = argument;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true;
process.Start();
process.BeginOutputReadLine();
process.WaitForExit();
return results;
}
static void process_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
string stringResults = (string)e.Data;
.
.
do some work on stringResults...
.
.
results = stringResults;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,如何将process_OutputDataReceived中的数据发送回myProcess?我不能使用单例,因为有可能在多个线程中执行此过程.
我有2个字符串,A和B. A包含"HelloHowAreYou".B包含"宾果".我想用字符串B替换字符串A,结果是"BingoHowAreYou".关于如何做到这一点的任何提示?即使是关键字也足够了.
我知道这是一个新手,但我不想只是为了找到这个简单的东西来寻找所有msdn doc.正如我所说,指向正确方向的简单指南/关键字就足够了.
编辑:
假设我不知道字符串的内容.我可以使用替换吗?谢谢你的快速回复.
我想创建一个具有加密强大的随机值序列的文件.这是代码
int bufferLength = 719585280;
byte[] random = new byte[bufferLength];
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
rng.GetBytes(random);
File.WriteAllBytes("crypto.bin",random);
Run Code Online (Sandbox Code Playgroud)
问题是它在rng.GetBytes(random);返回OutOfMemoryException.我需要一个具有这种大小的文件(不多也不少).我怎么解决这个问题?谢谢.