您好,这是我在vb.net中使用ms visual studio 2010的第一个项目,我想创建一个可以将参数发送到transact-sql数据库中的存储过程的类,我知道如何在vb 6中执行它,但我不是确定这是否是在这里做到的正确方法.
Imports System.Data.SqlClient
Public Class ClsLineas
Public Sub Inserta(ByVal GridLineas As DataGrid, _
ByVal numero As String, _
ByVal tipo As String, _
ByVal estado As String, _
ByVal anexo As Integer, _
ByVal fechaInicio As String, _
ByVal fechaFin As String, _
ByVal pcReg As String, _
ByVal observaciones As String, _
ByVal usuReg As String)
Dim cnx As SqlConnection = New SqlConnection(ClsCon.connectionString)
'ClsCon.connectionString is a class that contains the connection string
Dim cmd As …Run Code Online (Sandbox Code Playgroud) 当第一行被占用时,如何将图片转到下一行?
以下是我目前的代码:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBlock Text="Picture" Style="{StaticResource PhoneTextNormalStyle}"/>
<ListBox x:Name="picList" ScrollViewer.HorizontalScrollBarVisibility="Auto">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Image Source="{Binding Picture}" Height="80" Width="80"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
Run Code Online (Sandbox Code Playgroud) 我有以下代码:
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
char *MASTER_PASSWORD = "password";
bool login(char * password){
bool is_logged_in=false;
char buf[8];
strcpy(buf,password);
if(strcmp(buf, MASTER_PASSWORD)==0){
is_logged_in=true;
}
return is_logged_in;
}
int main(int argc, char *argv[]){
if(argc <2)
{
printf("Syntax: %s <input string>\n", argv[0]);
exit (0);
}
if(login(argv[1]))
printf("you are authorized");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我正在使用gdb来调试它,我需要知道is_logged_in堆栈中保存的值的位置.我怎样才能做到这一点?
下面是我可以创建的用于反转String的最快代码
public static void ReverseFast(string x)
{
string text = x;
StringBuilder reverse = new StringBuilder();
for (int i = text.Length - 1; i >= 0; i--)
{
reverse.Append(text[i]);
}
Console.WriteLine(reverse);
}
Run Code Online (Sandbox Code Playgroud)
我想解决这个等式中的每个瓶颈,使其尽可能快.到目前为止我唯一能找到的是阵列边界检查,我只是部分理解.无论如何,如果您使用.Length编译器决定不检查边界但是如果您正在递减,因为我理解它是否仍然禁用for它,它仍然进行边界检查?有人可以将此转换为使用指针,这将避免边界检查,我想测试100k +字符范围内的字符串的速度差异.
根据下面的评论和帖子,这是我到目前为止所提出的.
public static void ReverseFast(string x)
{
StringBuilder reverse = new StringBuilder(x.Length);
for (int i = x.Length - 1; i >= 0; i--)
{
reverse.Append(x[i]);
}
Console.WriteLine(reverse);
}
Run Code Online (Sandbox Code Playgroud)
上述解决方案比建议的重复问题答案快得多.这个问题实际上是在5000*26个字符+范围内解决逆转问题.我仍然希望使用指针来测试它,以确定是否没有瓶颈,尤其是如此大量的字符.
processPath在这个例子中是否可以从 返回参数?
这可能更有意义,抱歉。
Dim processName As String
Dim processPath As String
If processName = "cmd" Then
Dim arguments As String() = Environment.GetCommandLineArgs()
Console.WriteLine("GetCommandLineArgs: {0}", String.Join(", ", arguments))
End If
Run Code Online (Sandbox Code Playgroud) 我有这样的结构:
<tr>
<td onClick="doSomeStuff();">
<a href="#" onClick="doOtherStuff(1);">1</a>
<a href="#" onClick="doOtherStuff(2);">1</a>
</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
我的问题是doSomeStuff()总是执行,无论我点击一个<a href>元素.
我怎么解决这个问题?
byte[] result = memStream.ToArray();
memStream.Close();
byte[] temp = result.Take(255);
var str = System.Text.Encoding.Default.GetString(temp);
Run Code Online (Sandbox Code Playgroud)
上面的失败就result.Take(255);行了.它说我不能转换IEnumerable到byte[],并询问如果我错过了一个演员.
我是C#的新手,不确定该怎么做.
我可以通过调用MVC C#驱动程序来上传AJAX文件,但是浏览器会刷新并重新加载页面。
但是,如果我发表评论,仅当文件保存在服务器上时,不会发生将文件保存在驱动程序中的行。 File.SaveAs (fname);
MVC控制器:
[HttpPost]
public ActionResult UploadDocument()
{
if (Request.Files.Count > 0)
{
try
{
FileUpdateDto fileModal = new FileUpdateDto();
HttpFileCollectionBase files = Request.Files;
for (int i = 0; i < files.Count; i++)
{
HttpPostedFileBase file = files[i];
string fname;
DirectoryInfo directory = new DirectoryInfo(Server.MapPath("~/Content/Document/" + UserId).ToString());
if (!directory.Exists)
{
Directory.CreateDirectory(Server.MapPath("~/Content/Document/" + UserId).ToString());
}
if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
{
string[] testfiles = file.FileName.Split(new char[] { '\\' });
fname = testfiles[testfiles.Length - 1];
} …Run Code Online (Sandbox Code Playgroud) 我正在运行以下程序,并在程序到达后第一次迭代时出现溢出错误a.根据我的理解,这不应该发生,因为我使用的是具有荒谬容量的双打,并且是Long,但是因为它目前只有100个,所以它应该没关系,并且代码在此之前很久就失败了.这是我原来的输入:
h0 = 1000, v0 = 0, a0 = g = -9.80665, dt = .01, m = 752.2528, b = .287875
Run Code Online (Sandbox Code Playgroud)
这是代码:
Sub drag()
Dim h0 As Double
Dim v0 As Double
Dim a0 As Double
Dim dt As Double
Dim m As Double
Dim b As Double
Dim g As Double
Dim i As Long
Dim h As Double
Dim v As Double
Dim a As Double
h0 = Worksheets("Drag").Cells(2, 8).Value
v0 = Worksheets("Drag").Cells(2, 9).Value
a0 = …Run Code Online (Sandbox Code Playgroud) 为什么在C#中允许这样做?
dynamic abc = 123;
abc = 'ashwin';
Run Code Online (Sandbox Code Playgroud)
我们正在运行时更改对象的类型,但是我们知道C#是类型安全的,那么为什么它允许我们这样做?
看一下编译器输出:
c# ×5
vb.net ×2
command-line ×1
excel ×1
excel-vba ×1
gdb ×1
html ×1
javascript ×1
pointers ×1
sql-server ×1
stack ×1
take ×1
vb.net-2010 ×1
vba ×1
xaml ×1