我正在使用normalize函数从String中获取绝对路径,
org.apache.commons.io.FilenameUtils.normalize(String)
Run Code Online (Sandbox Code Playgroud)
但是,当我使用时,normalize(String)我得到:
对于MyClass类型,方法normalize(String)未定义
我试过了 : import org.apache.commons.io.FilenameUtils;
我从Apache网站下载了该库,并将其链接到我的项目,但我得到了同样的错误.
我不想每次都写整行来调用函数.
这有什么解决方案吗?
谢谢
让我们考虑这个例子:
public class Shared {
private int attribute;
public Shared() {}
public void incrementAttribute(int i) {
attribute += i;
}
public int getAttribute() {
return attribute;
}
public static void main(String[] args) {
Shared s1 = new Shared();
Shared s2 = new Shared();
s1.incrementAttribute(1);
s2.incrementAttribute(1);
s1.getAttribute();
s2.getAttribute();
}
}
Run Code Online (Sandbox Code Playgroud)
如何1 2在调用时将此类更改为输出,getAttribute()而不是1 1
像全局变量,我尝试了final关键字,但我不能使用方法设置.
我开发了一个WCF应用程序,我想将它打包成一个程序,可以由普通用户安装,而无需在他的机器上安装Visual Studio或IIS.
将使用机器IP地址从另一个机器远程调用此WCF.
你对这个案子有什么建议?
我使用Visual Studio 2010 Express All-In-One来安装Visaul C#和Visual Web Developer.
一旦我打开Visual C#并尝试创建WCF应用程序,我找不到它.
在互联网上查看后,我发现了一个在stackoverflow上做的提示.
我完全像那个人解释过,现在我有WCFServiceProject.

现在一切似乎都是正确的,but当我尝试创建一个WCF项目时,我得到了这个错误

有任何想法吗 ?
我有两个Froms(Form1,Form2),当我尝试从Form1类调用Form2的公共函数时,我收到此错误.
错误1'System.Windows.Forms.Form'不包含'getText1'的定义,并且没有可以找到接受类型'System.Windows.Forms.Form'的第一个参数的扩展方法'getText1'(你错过了吗? using指令或程序集引用?)C:\ Users ...\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs 24 17 WindowsFormsApplication1.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form gen = new Form2();
gen.ShowDialog();
gen.getText1(); // I'm getting the error here !!!
}
}
public partial class Form2 : Form
{
public string Text1;
public Form2()
{
InitializeComponent();
}
public string getText1()
{
return Text1;
}
public void setText1(string txt)
{
Text1 = txt;
}
private void button1_Click(object sender, EventArgs e) …Run Code Online (Sandbox Code Playgroud) 循环时是否可以获取当前索引?
for (int i = 0; i < DGV.Rows.Count - 2; i++)
{
myValue = DGV.CurrentRow.Index + " " + DGV.Rows[i].Cells[1].Value.ToString();
}
Run Code Online (Sandbox Code Playgroud)
但我有输出:
0 First
0 Second
0 ...
Run Code Online (Sandbox Code Playgroud)
我想得到:
1 First
2 Second
3 ...
Run Code Online (Sandbox Code Playgroud)
谢谢.
我想创建一个这样的List:
List<int, DateTime> foo = new List<int, DateTime>();
Run Code Online (Sandbox Code Playgroud)
但我得到这个错误:
Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments
是否有可能在C#中做到这一点?
只是想问一下在.NET Framewok(C#)中使用具有300多个属性的对象的缺点(我的意思是内存或响应时间).
我想在不同的类中分离属性,但我的问题是属性之间没有很大的关系.
我不会做任何复杂的计算,我只会填充instatiaded对象的属性并将他发送到另一个程序,这将把他送回去.
你怎么看
EDIT
运行我的程序时,我只有一个对象.
我想使用一个免费的数据库在我的WPF应用程序(PixelSense)中进行一些数据绑定(存储).
我已经在Visual Studio 2010中使用过SQL Server 2010,它的工作原理非常好.
我也听说过,由于一些不兼容问题,实体框架对MySQL不起作用,而且SQLite不支持布尔.
在这种情况下,你对我有什么建议?
Edit
谢谢,我选择了Microsoft SQL Server 2008 R2 Express
为什么:Free通过Microsoft,几乎相同SQL Server
我正在使用Roslyn在运行时执行C#代码.
首先我尝试了这个代码(工作正常):
engine.Execute(@"System.Console.WriteLine(""Hello World"");");
Run Code Online (Sandbox Code Playgroud)
之后,我想从文本文件中执行代码,所以我这样做了:
string line;
System.IO.StreamReader file = new System.IO.StreamReader("test.txt");
while ((line = file.ReadLine()) != null)
{
engine.Execute(line);
}
Run Code Online (Sandbox Code Playgroud)
我将之前使用的字符串复制到名为test.txt的外部文件中.
所以我的test.txt包含以下行: @"System.Console.Write(""Hello World"");"
当编译代码时,我得到一个错误,错过了什么.
所以我发现,这只是反斜杠.
并将代码更改为:
string line;
System.IO.StreamReader file = new System.IO.StreamReader("test.txt");
while ((line = file.ReadLine()) != null)
{
string toto = line;
string titi = toto.Replace(@"\\", @"");
engine.Execute(toto);
}
Run Code Online (Sandbox Code Playgroud)
现在,当我运行此代码时,没有任何反应(没有错误).
当我检查变量内容时,我得到了这个:
toto : "@\"System.Console.Write(\"\"Hello World\"\");\""
titi : "@\"System.Console.Write(\"\"Hello World\"\");\""
这是正常的!通常应删除baskslash,但事实并非如此.
有什么问题
EDIT
我想保留我在代码中传递给Roslyn的确切字符串,因此不建议更改文件中的字符串等答案.请另外解决!