在以下代码中,我将对象序列化为XML 字符串.
但是当我尝试使用XDocument.Parse 将此XML字符串读入XDocument时,它会给我这个错误:
根级别的数据无效.
XML是:
<?xml version="1.0" encoding="utf-8"?>
<Customer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Id>1</Id>
<FirstName>Jim</FirstName>
<LastName>Jones</LastName>
<ZipCode>23434</ZipCode>
</Customer>
Run Code Online (Sandbox Code Playgroud)
更新:这是十六进制:
![alt text][1] Mod编辑 - 禁用超链接:恶意软件的链接
我该如何处理这个XML,以便它在没有错误的情况下读入XDocument?
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.IO;
using System.Xml;
using System.Text;
using System.Xml.Linq;
namespace TestSerialize2342
{
class Program
{
static void Main(string[] args)
{
List<Customer> customers = Customer.GetCustomers();
Console.WriteLine("--- Serializing ------------------");
foreach (var customer in customers)
{
Console.WriteLine("Serializing " + customer.GetFullName() + "...");
string xml = XmlHelpers.SerializeObject<Customer>(customer); …Run Code Online (Sandbox Code Playgroud) 我刚刚看到一个类(一个很大的API模块),其中有很多类似的东西
readParamString(Object params, int index)
Run Code Online (Sandbox Code Playgroud)
他们在那个班级有10个领域
final static int PARAM1 = 1
...
final static int PARAM10 = 10
Run Code Online (Sandbox Code Playgroud)
与readParam函数一起使用
但你也可以使用普通的int readParamString(o, 1);
最终的静态int比使用普通的int更好吗?
每个人都把它称为C中的套接字编程或网络编程,我们通过使用包括sys/socket.h&开始使用它netinet/in.h.我们认为这是100%真实.但是当我看到这本书时,脑子里浮现出一些问题
网络互联使用TCP/IP第三卷:客户端 - 服务器编程和应用程序,有4种不同版本
我糊涂了.这清楚地表明Socket API没有标准.
我也很惊讶地看到sys/socket.h:netinet/in.h这是POSIX的C库中的一部分http://en.wikipedia.org/wiki/Berkeley_sockets.我现在更困惑了.
我写了一些Python,其中一些行的长度超过80个字符,这是我需要保持的阈值.如何调整代码以减少行长?
老师正在黑板上写字,我们希望通过低带宽网络实时传递黑板上的所有信息.我们该怎么做呢?
在一次采访中,我遇到了这个问题.
如何使用SQL通过QueryExpress或QueryAnalyser从SQL Server Windows模式更改为混合模式?
我做了这个功课.并以下列方式解决了它.我需要你的意见是否是一个好的方法,或者我需要使用任何其他数据结构以更好的方式解决它.
public string ReturnCommon(string firstString, string scndString)
{
StringBuilder newStb = new StringBuilder();
if (firstString != null && scndString != null)
{
foreach (char ichar in firstString)
{
if (!newStb.ToString().Contains(ichar) && scndString.Contains(ichar))
newStb.Append(ichar);
}
}
return newStb.ToString();
}
Run Code Online (Sandbox Code Playgroud) 这听起来很有趣......只是一个小实验.
我想使用发送消息模拟应用程序/窗口上文件的拖放.可能吗?
我没有应用程序的代码,但在可执行文件上.
该应用程序是IP Messenger.
我想要做的是使用"发送到"功能将文件发送到.exe,它将
找到IPMessenger窗口并模拟拖放thr代码.
用户将选择该文件,然后右键单击"发送到".exe,它将从代码中拖放.
**注意:IP Messenger支持文件的拖放操作
thx
amit
我有一个基类,有一个方法,我想使用泛型来强制编码器在当前类上使用泛型表达式:
public class TestClass
{
public void DoStuffWithFuncRef<T>(Expression<Func<T, object>> expression) where T : TestClass
{
this.DoStuffWithFuncRef(Property<T>.NameFor(expression));
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我想强制T为实例化类的类型,我希望这将导致C#编译器自动理解要使用的泛型类型.例如,我想避免编写下面的doStuff方法,我必须指定正确的类型 - 而是使用doStuffILikeButCannotGetToWork方法:
public class SubTestClass : TestClass
{
public string AProperty { get; set; }
public void doStuff()
{
this.DoStuffWithFuncRef<SubTestClass>(e => e.AProperty);
}
public void doStuffILikeButCannotGetToWork()
{
this.DoStuffWithFuncRef(e => e.AProperty);
}
}
Run Code Online (Sandbox Code Playgroud)
这可能吗?我应该以不同的方式做这件事吗?
我对Heap,Young,Tenured和Perm一代感到困惑.
有人可以解释一下吗?
c# ×4
algorithm ×2
java ×2
.net ×1
c++ ×1
generics ×1
heap-memory ×1
jvm ×1
linq-to-xml ×1
networking ×1
pep8 ×1
posix ×1
python ×1
sendmessage ×1
sockets ×1
sql-server ×1
winapi ×1
winsock ×1
xml ×1