我有以下(作为示例)XML文件和XSD.
<?xml version="1.0" encoding="utf-8" ?>
<foo>
<DateVal>2010-02-18T01:02:03</DateVal>
<TimeVal>PT10H5M3S</TimeVal>
</foo>
Run Code Online (Sandbox Code Playgroud)
和
version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="foo">
<xs:complexType>
<xs:sequence>
<xs:element name="DateVal" type="xs:dateTime" />
<xs:element name="TimeVal" type="xs:duration" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)
然后是以下C#代码:
static void Main(string[] args)
{
XmlDocument xd = new XmlDocument();
XmlSchema xs;
using (var fs = File.OpenRead(FilePath + "SimpleFields.xsd"))
{
xs = XmlSchema.Read(fs, null);
}
xd.Schemas.Add(xs);
xd.Load((FilePath + "SimpleFields.xml"));
xd.Validate(null);
var el_root = xd.DocumentElement;
var el_date = (XmlElement)el_root.SelectSingleNode("./DateVal");
//WANTED: el_date.Value = 2010-02-18 01:02:03 (as a DateTime Object) …Run Code Online (Sandbox Code Playgroud) FieldInfo有一个IsStatic成员,但PropertyInfo没有.我想我只是忽略了我需要的东西.
Type type = someObject.GetType();
foreach (PropertyInfo pi in type.GetProperties())
{
// umm... Not sure how to tell if this property is static
}
Run Code Online (Sandbox Code Playgroud) 我试图在Visual Studio 2008中创建一个智能设备项目.
目标平台:Windows Mobile 5.0 Pocket PC SDK.
.NET Compact Framework版本:.NET Compact Framework 3.5
但是我收到以下错误:
我在实现IEnumerable接口的对象池中有以下代码.
public IEnumerable<T> ActiveNodes
{
get
{
for (int i = 0; i < _pool.Count; i++)
{
if (_pool[i].AvailableInPool)
{
yield return _pool[i];
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
据我所知(根据这个问题),这将产生垃圾,因为需要收集IEnumerable对象._pool中的所有元素都不会被收集,因为池的目的是保持对所有元素的引用以防止垃圾创建.
任何人都可以建议一种允许迭代_pool以便不生成垃圾的方法吗?
在池上迭代时,池中的所有项都AvailableInPool == true应该迭代.订单无关紧要.
由于技术原因,我无法使用ClickOnce自动更新我的.NET应用程序及其程序集.在.NET中处理自动更新的最佳方法是什么?
编译器在优化RELEASE构建方面做得很好,但有时候确保为本地函数关闭优化(但不是通过unticking来关闭整个项目Project Options > Optimize code)会很有用.
在C++中,这是使用以下内容实现的(#pragma通常注释掉):
#pragma optimize( "", off )
// Some code such as a function (but not the whole project)
#pragma optimize( "", on )
Run Code Online (Sandbox Code Playgroud)
C#中有等价物吗?
几个很好的答案建议用这个方法装饰MethodImplOptions.NoOptimization.这是在.NET 3.5中实现的,但不是在Compact Framework(CF)版本中.一个相关的后续问题是,是否相当于:
* projects targeting .NET 3.0 or earlier?
* projects deployed to a device such as Windows CE 6.0 using the .NET 3.5 CF?
Run Code Online (Sandbox Code Playgroud) .net c# optimization compact-framework compiler-optimization
尝试显示表单设计器时出错.
见错误图片:

屏幕代码:
public partial class frmCanalVenda : frmEdit
{
public frmCanalVenda(CanalVenda canal, Cliente cli)
: base(canal)
{
InitializeComponent();
bdsCliente.DataSource = cli;
eabBar.ReadOnlyView = false;
}
private void frmCanalVenda_Load(object sender, EventArgs e)
{
try
{
Cursor.Current = Cursors.WaitCursor;
bdsAgrupamento.DataSource = Agrupamento.GetAll(DatabaseAFV.Connection);
bdsCanal.DataSource = Canal.GetAll(DatabaseAFV.Connection);
bdsSubCanal.DataSource = SubCanal.GetAll(DatabaseAFV.Connection);
bdsEspecializacao.DataSource = Especializacao.GetAll(DatabaseAFV.Connection);
bdsOperacao.DataSource = Operacao.GetAll(DatabaseAFV.Connection);
bdsPorte.DataSource = Porte.GetAll(DatabaseAFV.Connection);
}
finally
{
Cursor.Current = Cursors.Default;
}
}
}
Run Code Online (Sandbox Code Playgroud)
图像的文本
要在加载设计器之前防止可能的数据丢失,必须解决以下错误:
价值不在预期范围内.
此错误的实例(1)
- 隐藏在Microsoft.VisualStudio.Shell.Design.Serialization.DesignerDocDataService的Microsoft.VisualStudio.NativeMethods.ThrowOnFailure(Int32 hr,Int32 [] expectedHRFailure)的System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode,IntPtr errorInfo)中的调用堆栈. Microsoft.VisualStudio.Design.Serialization上的Microsoft.VisualStudio.Shell.Design.Serialization.DesignerDocDataService.GetChildDocData(String name,FileAccess access,String createTemplate)中的GetFileDocData(String fileName,FileAccess …
forms compact-framework visual-studio-2008 windows-mobile-6.1 c#-3.0
在检查我的Windows移动设备上是否有摄像头并启用时,我遇到了一些我不理解的东西.
代码如下所示:
public static bool CameraP(){
return Microsoft.WindowsMobile.Status.SystemState.CameraPresent;
}
public static bool CameraE()
{
return Microsoft.WindowsMobile.Status.SystemState.CameraEnabled;
}
public static bool CameraPresent1()
{
return Microsoft.WindowsMobile.Status.SystemState.CameraPresent
&& Microsoft.WindowsMobile.Status.SystemState.CameraEnabled;
}
public static bool CameraPresent2()
{
return CameraP() && CameraE();
}
Run Code Online (Sandbox Code Playgroud)
当我调用CameraPresent2()它时返回false(没有相机存在).但是,当我打电话给CameraPresent1()我收到一个MissingMethodException并注释"找不到方法:get_CameraEnabled Microsoft.WindowsMobile.Status.SystemState."
第二个术语的评估CameraPresent1是因为它们都是属性(在语言层面)吗?
还有什么能解释行为上的差异吗?
我有一个detailcollection集合,每个细节都有
code, price, name
Run Code Online (Sandbox Code Playgroud)
并带有一些代码的字符串
string codes = "1,2,3";
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用数组 string.Split()
string[] codesarray = codes.Split(',');
Run Code Online (Sandbox Code Playgroud)
但是我如何才能获得产品codes呢?
// the idea I have, but I would not like to have a loop
for (int i = 0; i < codesarray.Length; i++)
{
detailcollection.Where(x => x.ope_idsku == codesarray[i])
}
Run Code Online (Sandbox Code Playgroud)
我想要像:
detailcollection.Where(x => x.ope_idsku not in (codesarray))
Run Code Online (Sandbox Code Playgroud) 我想为Windows CE 6.0目标设备开发Compact Framework App.我可以使用Visual Studio 2013执行此操作吗?
如果这不可能,那么.net紧凑框架的开发环境是什么?
.net compact-framework windows-ce visual-studio visual-studio-2013
c# ×8
.net ×4
windows-ce ×2
c#-3.0 ×1
forms ×1
iteration ×1
lambda ×1
optimization ×1
reflection ×1
winforms ×1
xml ×1
xmldocument ×1
xsd ×1