我有3个字符串,这些不是真正的数据只是一个例子:
string items = "Item 1, Item 2, Item 3";
string price = "300, 400, 500";
string tax = "30, 50, 60";
Run Code Online (Sandbox Code Playgroud)
我想要做的是创建一个这样的数组:
[Item 1] => Array([Price] => 300, [Tax] => 30), [Item 2] => Array([Price] => 400, [Tax] => 50), [Item 3] => Array([Price] => 500, [Tax] => 60)
Run Code Online (Sandbox Code Playgroud)
问题是我不知道如何在ASP.NET中执行此操作,如果我必须在PHP中执行此操作,这将没有问题.
我很新,当我说新的时候,我的意思是我刚刚开始今天早上,我有一个问题,我试图谷歌搜索,但似乎无法找到解决方案.
我有这个swift文件:
import UIKit
class ProntoController: UITableView {
var tableView:UITableView?
var items = NSMutableArray()
override func viewDidLoad() {
super.viewDidLoad()
}
func viewWillAppear(animated: Bool) {
NSLog("Here")
let url = "API.php"
NSURLSession.sharedSession().dataTaskWithURL(NSURL(string: url)!) { data, response, error in
NSLog("Success")
}.resume()
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.items.count;
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("CELL") as? UITableViewCell
return cell!
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是这部分代码: …
我想让UIWebView暂时显示google.com,但它没有加载:
我只是得到一个空白的屏幕
.H
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIWebView *webView;
@end
Run Code Online (Sandbox Code Playgroud)
.M
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *targetURL = [NSURL URLWithString:@"http://www.google.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[_webView loadRequest:request];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Run Code Online (Sandbox Code Playgroud)
我做的是创建Web视图的以下内容:
我尝试添加以下内容:
[self.view …Run Code Online (Sandbox Code Playgroud) 我在这里有这行代码:
command.Parameters["@DateCompleted"].Value = items[i].DateCompleted.Equals("01/01/0001 12:00:00 AM") ? null : items[i].DateCompleted;
Run Code Online (Sandbox Code Playgroud)
但是我收到了这个错误:
Type of conditional expression cannot be determined because there is no implicit conversion between '<null>' and 'System.DateTime'
Run Code Online (Sandbox Code Playgroud)
我想要做的是不使用01/01/0001 Date并使用null,因为该项为null.
附加代码:
command.Parameters.Add("@DateCompleted", System.Data.SqlDbType.DateTime);
Run Code Online (Sandbox Code Playgroud) 我有这个方法:
public List<CustomerQuestionsClass> updateCustomersQuestions(List<CustomerQuestionsClass> items)
{
connection = new SqlConnection(connectionString);
command = new SqlCommand(@"IF EXISTS(SELECT * FROM CustomerQuestions WHERE CustomerID = @CustomerID AND QuestionID = @QuestionID)
BEGIN
UPDATE CustomerQuestions SET selected = @Selected, ModifiedBy = @ModifiedBy, DateModified = @DateModified WHERE CustomerID = @CustomerID AND QuestionID = @QuestionID
END
ELSE
BEGIN
INSERT INTO CustomerQuestions (CustomerID, QuestionID, selected, CreatedBy,
DateCreated, ModifiedBy, DateModified, DateCompleted, DueDate)
VALUES (@CustomerID, @QuestionID, @Selected, @CreatedBy, @DateCreated,
@ModifiedBy, @DateModified, @DateCompleted, @DueDate)
END");
command.Parameters.Add("@CustomerID", System.Data.SqlDbType.Int);
command.Parameters.Add("@QuestionID", System.Data.SqlDbType.Int);
command.Parameters.Add("@Selected", System.Data.SqlDbType.Bit);
command.Parameters.Add("@CreatedBy", …Run Code Online (Sandbox Code Playgroud) 我有一个这样的课程:
public class OverDueClass
{
public int CustomerID { get; set; }
public int Question_ID { get; set; }
public string Department { get; set; }
public DateTime DueDate { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我正在填充这个类并将它传递给另一个方法:
while (dataReader.Read())
{
OverDueClass overDueItem = new OverDueClass();
overDueItem.CustomerID = (int)dataReader[0];
overDueItem.Question_ID = (int)dataReader[1];
overDueItem.Department = dataReader[2].ToString();
overDueItem.DueDate = (DateTime)dataReader[3];
OverDueCell.Add(overDueItem);
}
sendEmail("fake@email.com", OverDueCell);
Run Code Online (Sandbox Code Playgroud)
现在在另一种方法中,我可以看到正在传递数据。
现在我正在尝试运行 aforeach来处理数据,我尝试了以下操作:
foreach(string item in overDue)
{
}
Run Code Online (Sandbox Code Playgroud)
但我收到此错误:
无法将类型转换为字符串。
我有这个附加声明
$("#questions").append($("<tr><td>" + if(value.NA == true) { + "<input type='checkbox' id='" + value.Question_ID + "-na' class='na' /> " + } + "</td>");
Run Code Online (Sandbox Code Playgroud)
我正在尝试向追加添加条件,但是我收到此错误:
Uncaught SyntaxError: Unexpected token if
Run Code Online (Sandbox Code Playgroud)
我假设这是非法的,什么是完成我想要完成的最好的方法?
我有一个来自数据库的日期,如下所示:
26/01/2016 12:00:00 AM
Run Code Online (Sandbox Code Playgroud)
我把它作为一个字符串捕获
questionItem.DueDate = dataReader[6].ToString();
Run Code Online (Sandbox Code Playgroud)
我试图重新格式化这个字符串,使其看起来像
2016-01-26
Run Code Online (Sandbox Code Playgroud)
我该怎么做?
我在这里有这个代码,基本上它需要一个数组遍历每个项目并将其添加到一个字符串末尾和循环后的逗号,删除最后一个逗号:
NSString *areaDescriptionWSpaceCharacters = nil;
for(NSString *item in areaDescription)
{
[areaDescriptionWSpaceCharacters stringByAppendingString:[NSString stringWithFormat: @"%@,", item]];
}
areaDescriptionWSpaceCharacters = [areaDescriptionWSpaceCharacters substringToIndex:[areaDescriptionWSpaceCharacters length] - 1];
Run Code Online (Sandbox Code Playgroud)
但是areaDescriptionWSpaceCharacters返回nil.为什么?
我试图获取用户的位置很长,但我做了以下工作:
导入的核心位置
import CoreLocation
Run Code Online (Sandbox Code Playgroud)
添加核心位置代表
class ViewController: UIViewController, CLLocationManagerDelegate, AVCaptureMetadataOutputObjectsDelegate, DTDeviceDelegate {
Run Code Online (Sandbox Code Playgroud)
定义了这个变量:
var locationManager: CLLocationManager!
Run Code Online (Sandbox Code Playgroud)
然后添加此方法:
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let userLocation:CLLocation = locations[0]
let long = userLocation.coordinate.longitude;
let lat = userLocation.coordinate.latitude;
print(long, lat)
//Do What ever you want with it
}
Run Code Online (Sandbox Code Playgroud)
但该位置未得到打印,我的方法甚至没有得到它。
我将要使用“核心位置”的项目添加到我的列表中,并且该应用在我第一次运行时要求我使用位置服务。但是现在位置正在打印中。...我在做什么错?
asp.net ×5
c# ×5
ios ×3
objective-c ×2
swift ×2
foreach ×1
jquery ×1
sql-server ×1
uitableview ×1
uiwebview ×1