小编Mat*_*hew的帖子

货币转换器Web服务

我想在我的网站上使用货币转换网络服务.我添加了对.asmx文件的引用.

这是我的代码:

net.webservicex.www.CurrencyConvertor Convertor; //creating instance of web service

float new_donation = donation * Convertor.ConversionRate("EUR", "GBP"); //converting donation to new value
Run Code Online (Sandbox Code Playgroud)

问题是我发布的第二行给出了以下错误:

'abc.net.webservicex.www.CurrencyConvertor.ConversionRate(abc.net.webservicex.www.Currency,abc.net.webservicex.www.Currency)'的最佳重载方法匹配有一些无效的参数

参数1:无法从'string'转换为'abc.net.webservicex.www.Currency'

参数2:无法从'string'转换为'abc.net.webservicex.www.Currency'

以下是Web服务描述的链接:

http://www.webservicex.net/ws/wsdetails.aspx?wsid=10

我怎么解决这个问题?先感谢您.

c# service currency web

2
推荐指数
1
解决办法
1万
查看次数

C - 使用strncpy()函数后的随机字符

我在C中有以下程序:

该程序的主要问题是,在执行复制操作后,复制的字母后会显示许多垃圾字符.我知道这是因为目标变量没有正确地以null结尾.但是,如果仔细检查代码,我将执行空终止.为什么问题仍然存在?

c null integer termination

2
推荐指数
3
解决办法
3600
查看次数

在Visual Studio 2010和Windows中使用文件描述符

我有一个C++程序,它接受用户的一些文本并将其保存到文本文件中.以下是该计划的片段:

#include "stdafx.h"
#include <ctime>
#include <fcntl.h>
#include <iostream>
#include <string>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <Windows.h>

using namespace std;

int file_descriptor;
size_t nob;

int check_file(const char* full_path) //Method to check whether a file already exists
{
    file_descriptor = open(full_path, O_CREAT | O_RDWR, 0777); //Checking whether the file exists and saving its properties into a file descriptor
}

void write_to_file(const char* text) //Method to create a file and write the text to it
{ …
Run Code Online (Sandbox Code Playgroud)

c++ file file-descriptor

2
推荐指数
1
解决办法
8478
查看次数

如何附加到文本文件?

我有一个用C++编写的程序,它接受用户的文本并使用文件句柄将其保存到文本文件中.以下是该计划的片段:

该程序工作正常.唯一的问题是它不会将文本附加到文本文件中.相反,它"删除"所有现有文本并仅保存新文本.

也就是说,丢弃在程序的先前会话中保存的文本,而是保存新文本.我该如何解决这个问题?

c c++ file handles

2
推荐指数
1
解决办法
298
查看次数

迭代字符串输入

我试图迭代一个字符串,看看输入是否是一个整数.

这是代码:

 for (int i = 1; i < strlen(buffer); i++) //Checking that each character of the string is numeric
    {
        if (!isdigit(buffer[i]))
        {
            valid = false;
            break;
        }
    }

    if(valid == false)
    {
        printf("Invalid input!");
    }

    else
    {
        num = atoi(buffer);
        printf("The number entered is %d", num);
    }
Run Code Online (Sandbox Code Playgroud)

问题是即使输入正确,让我们说2,输出消息仍然是"输入无效!".

我现在非常沮丧.我已经尝试使用atoi函数,strtol函数和其他方法,以便我可以验证一个数字并确保:

1)它不是字母2)它是一个整数

请帮我.我一直试图解决这个问题超过2个小时.

c validation integer input fgets

2
推荐指数
1
解决办法
171
查看次数

Windows Phone - 使页面可滚动

我在windows phone app的xaml文件中有以下代码:

<!--ContentPanel - place additional content here-->
        <ScrollViewer>
            <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">            

                <Button Content="Save Details" Height="72" HorizontalAlignment="Left" Margin="9,870,0,0" Name="Button_SaveDetails" VerticalAlignment="Top" Width="216" />
                <Button Content="Cancel" Height="72" HorizontalAlignment="Left" Margin="296,870,0,0" Name="Button_Cancel" VerticalAlignment="Top" Width="160" />
            </Grid>
        </ScrollViewer>
    </Grid>
Run Code Online (Sandbox Code Playgroud)

现在,即使页面可滚动,我也有两个问题:

1)一些内容出现在应用程序标题后面2)底部的按钮不完全可见(不完全滚动到底部)

这是显示第一个问题的屏幕截图

在此输入图像描述

我该如何解决这两个问题呢?谢谢

c# windows-phone

2
推荐指数
1
解决办法
4729
查看次数

跟踪按钮点击次数

我们假设我有一个带有CAPTCHA图像的页面.

我想让用户尝试输入代码三次,否则他不再允许这样做.

如何跟踪单击"确认"按钮的次数.每次单击时,"确认"按钮都必须对服务器执行回发.

使用JavaScript并不好,因为如果用户重新加载页面,计数器将设置为零.怎么可以这样做呢?

c# asp.net click button

2
推荐指数
1
解决办法
3308
查看次数

C 中 _int8 数据类型的格式说明符

_int8 数据类型的格式说明符是什么?

我正在使用“%hd”,但它给我一个关于堆栈损坏的错误。谢谢 :)

这是代码片段:

signed _int8 answer;

printf("----Technology Quiz----\n\n");
printf("The IPad came out in which year?\n");
printf("Year: ");
scanf("%hd", &answer);
printf("\n\n");
printf("The answer you provided was: %hd\n\n", answer);
Run Code Online (Sandbox Code Playgroud)

c integer overflow

1
推荐指数
1
解决办法
1万
查看次数

输入超出范围的char号时,程序立即退出

我有一个用C编写的程序.以下是该程序的片段:

signed char answer;

printf("----Technology Quiz----\n\n");
printf("The IPad came out in which year?\n");
printf("Year: ");
scanf("%c", &answer);
printf("\n\n");
printf("The answer you provided was: %c\n\n", answer);
Run Code Online (Sandbox Code Playgroud)

这不是整个计划.在此代码之后,有一个检查,用于验证用户是否猜到了年份.

正如您所看到的,用户永远无法猜出答案,因为签名的char只接受-128到127的输入.这是故意的.

这个程序的问题是如果用户输入一个字符范围之外的数字,程序就会立即退出.该程序的行为就好像最后没有getchar(),即使有.我该如何解决这个问题?

编辑

如果输入超出范围,则程序的行为类似于用户忘记在最后包含getchar()的应用程序.

c integer char exit

1
推荐指数
1
解决办法
525
查看次数

在web.config文件中存储公钥

我试图将公钥存储在ASP.NET网站的web.config文件中,如下所示:

<add key="public_key" value="<RSAKeyValue><Modulus>zDYX4tbHSyTrwDmjSXiiFTo0ydGK50zxtH2lGL90oWrshMGy16wod7AZMfm8CMd/Rxl3ocIPLTmHSwyBb0xzL6lnF8uJI90s2TBHYemx3tkRQCcW6PZfGBWwlwSzhaNidbibRtoWNImBG4ehzc5Yxg3r6IyUBEtY9xJkL1tIezU=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>"/>
Run Code Online (Sandbox Code Playgroud)

此代码位于web.config文件的appSettings部分中.不幸的是,它给了我以下警告以及其他一些错误:

Warning 6   The element 'appSettings' has invalid child element 'RSAKeyValue'. List of possible elements expected: 'add, remove, clear'.
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?谢谢 :)

c# asp.net key public

1
推荐指数
1
解决办法
2031
查看次数