我想为BlackJack游戏初始化一个Player对象数组.我已经阅读了很多关于初始化原始对象的各种方法,比如一个int数组或一个字符串数组但是我不能把这个概念带到我想要做的事情(见下文).我想返回一个初始化的Player对象数组.要创建的播放器对象的数量是一个整数,我会提示用户.我在想,构造函数可以接受一个整数值,并在初始化Player对象的某些成员变量时相应地命名播放器.我觉得我很亲密,但仍然很困惑.
static class Player
{
private String Name;
private int handValue;
private boolean BlackJack;
private TheCard[] Hand;
public Player(int i)
{
if (i == 0)
{
this.Name = "Dealer";
}
else
{
this.Name = "Player_" + String.valueOf(i);
}
this.handValue = 0;
this.BlackJack = false;
this.Hand = new TheCard[2];
}
}
private static Player[] InitializePlayers(int PlayerCount)
{ //The line below never completes after applying the suggested change
Player[PlayerCount] thePlayers;
for(int i = 0; i < PlayerCount + 1; i++)
{
thePlayers[i] …Run Code Online (Sandbox Code Playgroud) 我最近安装了Visual Studio Community 2015,我一直在关注MSDN教程"使用Xamarin构建跨平台应用程序".在设计应用程序外观的时候,我选择了Resources\layout文件夹中的Main.axml文件,Android设计器失败了:
安装的Android SDK太旧了.需要版本24.3.4或更新版本.请更新到最新版本.
我做了很多搜索,发现其中一个较新版本的Android SDK导致Xamarin Android设计器失败.我找到了一个版本24.4.1,表明这个设计师问题是固定的.
如何更新Visual Studio的这一部分(即Xamarin.Android)?以下是我在Windows 7上安装的一小部分:

我还是C#的新手,我一直在努力解决阵列上的各种问题.我有一组元数据对象(名称值对),我想知道如何只创建我真正需要的"InputProperty"对象的数量.在这个循环中,我任意设置元素的数量为20,当条目变为null时我试图挽救但是接收端的Web服务不喜欢传递给它的任何null元素:
private Update BuildMetaData(MetaData[] nvPairs)
{
Update update = new Update();
InputProperty[] ip = new InputProperty[20]; // how to make this "dynamic"
int i;
for (i = 0; i < nvPairs.Length; i++)
{
if (nvPairs[i] == null) break;
ip[i] = new InputProperty();
ip[i].Name = "udf:" + nvPairs[i].Name;
ip[i].Val = nvPairs[i].Value;
}
update.Items = ip;
return update;
}
Run Code Online (Sandbox Code Playgroud)
总之,假设我在上面的输入数组中只有3个名值对?不是为名为ip的数组分配20个元素,而是如何对此进行编码,以便ip只有它需要的大.更新对象通过另一个Web服务传递,因此序列化很重要(即我不能使用namevaluecollection等).
ps是通过"添加评论"工具跟踪已发布问题的唯一方法吗?
我是Java和Eclipse的新手.我google了很多帮助,但仍然困惑.在Eclipse我点击Run选择Java应用程序,我立即得到这个错误.这是我的源代码:
import java.util.Arrays;
import java.util.Scanner;
public class SliceandDice {
void main(String args[]) {
System.out.println("This is the BIGGEST program console");
System.out.println("Each input line will be a pair of numbers separated by a COMMA.");
System.out.println("First number must be an unsigned number less than 10000. Max example: 9999");
System.out.println("Second number is the 'target' number.");
System.out.println("Example of an input line to be typed:");
System.out.println(" 4721 , 75");
for (int i = 1; i < 6; i++) // each time in this loop, we have …Run Code Online (Sandbox Code Playgroud) 当我需要从Web服务器上的目录中删除一些图像文件时,我有一些代码可以正常工作:
Dim ImageURL As String = dsImages.Tables(0).Rows(iImgRow).Item("ImageURL")
Dim physicalName = Server.MapPath(ImageURL)
oUpload.DeleteFileFromServer(physicalName, iAdid, iImgID)
Run Code Online (Sandbox Code Playgroud)
..但是当以设定的时间间隔在单独的线程中运行的维护任务确定需要删除上述文件时,我遇到了问题:
Dim ImageURL As String = dsImage.Tables(0).Rows(i - 1).Item("ImageURL")
Dim iImgID As Integer = dsImage.Tables(0).Rows(i - 1).Item("ImageId")
Dim physicalName As String = HttpContext.Current.Server.MapPath(ImageURL)
oUpload.DeleteFileFromServer(physicalName, iAdID, iImgID)
Run Code Online (Sandbox Code Playgroud)
在后一种情况下,HttpContext.Current.Server.MapPath(ImageURL)的值为Nothing.
有没有办法获得这种情况的完整路径?
我正在尝试在Web服务中重载方法但是在Visual Studio 2005中尝试"添加Web引用"时遇到System.InvalidOperationException(这是相关的代码片段):
public class FileService : System.Web.Services.WebService
{
private static readonly MetaData[] EmptyMetaData = new MetaData[0];
public FileService()
{
// a few innocent lines of constructor code here...
}
[WebMethod(MessageName = "UploadFileBasic",
Description = "Upload a file with no metadata properties")]
public string UploadFile(string trimURL
, byte[] incomingArray
, string fileName
, string TrimRecordTypeName)
{
return UploadFile(trimURL
, incomingArray
, fileName
, TrimRecordTypeName
, EmptyMetaData);
}
[WebMethod(MessageName = "UploadFile",
Description = "Upload a file with an array of metadata …Run Code Online (Sandbox Code Playgroud) 我有一个用C#编写的Windows桌面应用程序,它循环存储在磁盘上并由第三方程序创建的一堆XML文件.大多数所有文件都由此语句后面的LINQ代码成功加载和处理:
XDocument xmlDoc = XDocument.Load(inFileName);
List<DocMetaData> docList =
(from d in xmlDoc.Descendants("DOCUMENT")
select new DocMetaData
{
File = d.Element("FILE").SafeGetAttributeValue("filename")
,
Folder = d.Element("FOLDER").SafeGetAttributeValue("name")
,
ItemID = d.Elements("INDEX")
.Where(i => (string)i.Attribute("name") == "Item ID(idmId)")
.Select(i => (string)i.Attribute("value"))
.FirstOrDefault()
,
Comment = d.Elements("INDEX")
.Where(i => (string)i.Attribute("name") == "Comment(idmComment)")
.Select(i => (string)i.Attribute("value"))
.FirstOrDefault()
,
Title = d.Elements("INDEX")
.Where(i => (string)i.Attribute("name") == "Title(idmName)")
.Select(i => (string)i.Attribute("value"))
.FirstOrDefault()
,
DocClass = d.Elements("INDEX")
.Where(i => (string)i.Attribute("name") == "Document Class(idmDocType)")
.Select(i => (string)i.Attribute("value"))
.FirstOrDefault()
}
).ToList<DocMetaData>();
Run Code Online (Sandbox Code Playgroud)
...其中inFileName是一个完整的路径和文件名,例如: …
我已经阅读了很多关于如何做到这一点的帖子/文章,我仍然没有从内容页面获取页面标题集.我的页面渲染正常,但我无法从内容页面获取标题集(所有页面都根据母版页设置了标题).这是我的母版页的代码隐藏:
Partial Class zSEO
Inherits System.Web.UI.MasterPage
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Page.Header.Title = "Dynamically set in Master page"
End Sub
End Class
Run Code Online (Sandbox Code Playgroud)
这是母版页的其余部分:
<%@ Master Language="VB"
EnableTheming="true"
Inherits="zSEO"
CodeFile="zSEO.master.vb" %>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div id="container">
<div id="content">
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</div>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
然而,我想在网页内容页面中建立页面的价值,并将其放在我的测试内容页面中:
Public Partial Class zShowAd
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As …Run Code Online (Sandbox Code Playgroud) 我必须处理一个传递给我的函数的大字节数组.我需要将来自此传入字节数组的内容以较小的"块"复制到出站字节数组.
对于在出站阵列中创建的每个"数据块",我需要调用一个Web服务.
返回时,我需要继续循环传入的字节数组,继续传递整个或部分数据块,直到处理完整的传入数组(即以块为单位发送到Web服务).
我是C#的新手,我正在努力使用一个有效的循环.我知道如何调用Web服务来处理"块"但我无法正确循环.这是我目前可悲的混乱的草图:
int chunkSize = 10000;
byte[] outboundBuffer = new byte[chunkSize];
while (BytesRead > 0)
{
long i = 0;
foreach (byte x in incomingArray)
{
BytesRead += 1;
outboundBuffer[i] = incomingArray[i]
i++;
}
uploadObject.Size = BytesRead;
uploadObject.MTOMPayload = outboundBuffer;
// call web service here and pass the uploadObject
// get next "chunk" until incomingArray is fully processed
}
Run Code Online (Sandbox Code Playgroud)
我知道这是一团糟,不会奏效; 有人可以草拟一个合适的循环来完成这项工作吗?非常感谢.
目前,我的部分应用程序会向用户发送电子邮件,提醒他们注意事件或任务.当点击一个MarkComplete在电子邮件客户端的链接,一个HTTP GET请求我做ActionHandler.ashx(一个HttpHandler),其中的查询字符串参数的输入,允许事件/任务的更新.然后将新的电子邮件发送回客户端信令完成.这有效.
这种HTTP GET对处理程序的不良副作用是启动浏览器(即此时,浏览器的打开是不必要的并且是令人讨厌的).
前提:当我研究ASP.Net Web Api时,我想我可能能够将HTTPHandler中的少量代码重构为Web API控制器中的PUT方法.我的理解是,在执行上述所需的处理之后,该控制器可以用无效返回(HTTP状态代码204)进行响应.
问题:Web API控制器中新编写的PUT方法中的上述方法是否会返回204,这是否会阻止浏览器完全启动?我希望最终用户点击他第一封电子邮件中的链接,只获得新构建的电子邮件信号"完成"(此处根本没有浏览器).
编辑澄清2016年5月22日:
c# ×4
arrays ×2
asp.net ×2
java ×2
object ×2
vb.net ×2
android ×1
asmx ×1
bytearray ×1
eclipse ×1
email-client ×1
http ×1
httpcontext ×1
linq-to-xml ×1
master-pages ×1
title ×1
types ×1
web-services ×1
webforms ×1
xamarin ×1
xml ×1