在WPF中,如何使用反射来查找项目中的所有类?我有兴趣获得名称与某个正则表达式匹配的那些.
我有一个很大的值列表(100-200个字符串),我需要返回一个明确的列表.使用.NET执行此操作的最有效方法是什么?我能想到的两种方式是:
如果字典方法的原始速度更快,请考虑围绕代码可维护性的权衡决策.
我在xcode项目的资源中有一个带有Array类型的根的plist文件.在按钮上单击我需要访问此plist并查找plist是否已包含特定项目,如果没有将新项目(NSString)写入plist.
我这样做如下,
NSMutableArray *array = nil;
NSDictionary *dictionary = nil;
path = [[NSBundle mainBundle] pathForResource:@"MyPlistName" ofType:@"plist"];
array = [[NSMutableArray alloc] initWithContentsOfFile:path];
dictionary = [self.dictionary objectForKey:@"tag"];
if(![array containsObject:dictionary])
{
[array addObject:dictionary];
if(![array writeToFile:path atomically:YES])
{
NSLog(@".plist writing was unsucessfull");
}
}
Run Code Online (Sandbox Code Playgroud)
这对我在模拟器上有效,但是当我在设备上运行时,writeToFile:atomically方法似乎总是返回NO.
我甚至尝试过使用NSArchiver,即使这似乎也没有将NO作为返回值
谁能说出我做错了什么..
问候,
Syed Yusuf
我想NSLog
输出一个文字转义序列,而不将其视为一个模式.
举个例子NSLog(@"image%03d.jpg");
,我想要输出的是谁,image%03d.jpg
而不是image000.jpg
.
我已经尝试过各种各样的转义序列NSLog(@"image\\%03d.jpg");
,NSLog(@"image\\%03\\d.jpg");
并且NSLog(@"image%03\\d.jpg");
没有一个能够产生预期的结果.
当我包含一个我想要替换的实际模式时,问题只会进一步增长,在文字之后:NSLog(@"image\\%03d.jpg test %d", 1);
我想输出image%03d.jpg test 1
.
在Android应用中,我使用两个EditText
控件并将它们的两个值相乘.如果一个EditText
是,null
而在第二个我放了一个值,它就不能正常工作.我如何处理这种情况,我在一个EditText
和另一个null
中有一个值,我想将这两个值相乘?
我在 C# 中使用 PInvoke,尝试使用已知处理程序读取窗口中可见的工具提示,但是我尝试以这种方式检查的窗口应用程序因内存访问冲突错误而崩溃,或者根本不显示工具提示文本lpszText TOOLINFO 成员。
我正在使用回调调用EnumWindows,然后向该函数中的工具提示窗口发送一条消息:
public delegate bool CallBackPtr(IntPtr hwnd, IntPtr lParam);
static void Main(string[] args)
{
callBackPtr = new CallBackPtr(Report);
IntPtr hWnd = WindowFromPoint(<mouse coordinates point>);
if (hWnd != IntPtr.Zero)
{
Console.Out.WriteLine("Window with handle " + hWnd +
" and class name " +
getWindowClassName(hWnd));
EnumWindows(callBackPtr, hWnd);
Console.Out.WriteLine();
}
public static bool Report(IntPtr hWnd, IntPtr lParam)
{
String windowClassName = getWindowClassName(hWnd);
if (windowClassName.Contains("tool") &&
GetParent(hWnd) == lParam)
{
string szToolText = new string(' ', 250); …
Run Code Online (Sandbox Code Playgroud) 如何获得不基于PC时间的时间?我使用下面的代码来获取时间并且它可以工作,但是当我改变计算机时间时,时间不再正确,那么有没有办法可以获得实际的实时而不是PC时间?可能GPS时间?
private void btn_DateTime_Click(object sender, EventArgs e)
{
DateTime dateTime = DateTime.Now;
label_localTime.Text = dateTime.ToString();
DateTime utcNow = DateTime.UtcNow;
label_utc.Text = utcNow.ToString();
TimeZone timeZone = TimeZone.CurrentTimeZone;
if (timeZone.IsDaylightSavingTime(dateTime) == true)
{
label_dayLightSaving.Text = "YES";
label_timeZone.Text = timeZone.GetUtcOffset(dateTime).ToString();
}
else
{
label_dayLightSaving.Text = "NO";
label_timeZone.Text = "N//A";
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:目标设备在WM6上运行,它有GPS硬件.
谢谢.
如何在Borland C++中使用NaN初始化数字?
复制:在C++中使用NaN?
除了sqlite3之外,还有其他可以在iPhone上使用的数据库引擎吗?像textDb这样的东西适用于 PHP,单文件且无服务器。