使用多维数组获取父数组键的最佳方法是什么?例如,我有这个数组:
array(
[0] => array(0=> sample, 1=>picture, 2=>frame, 3=>google)
[1] => array(0=> iphone, 1=>orange, 2=>love, 3=>msn)
[2] => array(0=> joe, 1=>geee, 2=>panda, 3=>yahoo)
)
Run Code Online (Sandbox Code Playgroud)
现在我需要搜索例如google并获取父数组键..它应该是0 ...任何想法?我用它来循环,但我认为如果我有700000行的数组将会很慢..
我有两个数组,每个数组都有一些值,例如:
int a[] = {1, 2, 3, 4};
int b[] = {0, 1, 5, 6};
Run Code Online (Sandbox Code Playgroud)
现在我需要将数组(a)的元素与数组(b)中的元素进行比较..如果有任何匹配程序应该返回错误或打印"错误有重复值"等等.在上述情况,它应该返回一个错误coz a [0] = b [1],因为它们都有相同的值.
我怎样才能做到这一点??
我正在玩这个SAPI v5.1库.所以我正在测试我的样本WAV文件.(从这里下载).无论如何,该文件中的声音清晰简单.它只包含一个单词,即第三个单词.现在,当我运行以下代码时,我得到数字8或"8".如果我删除它,我得到7.如果我尝试随机化列表我得到不同的结果,依此类推.我真的很困惑,开始认为SAPI库中的SpeachRecognition根本不起作用......
无论如何这里是我正在做的,
private void button1_Click(object sender, EventArgs e)
{
//Add choices to grammar.
Choices mychoices = new Choices();
mychoices.Add("one");
mychoices.Add("two");
mychoices.Add("three");
mychoices.Add("four");
mychoices.Add("five");
mychoices.Add("six");
mychoices.Add("seven");
mychoices.Add("eight");
mychoices.Add("nine");
mychoices.Add("zero");
mychoices.Add("1");
mychoices.Add("2");
mychoices.Add("3");
mychoices.Add("4");
mychoices.Add("5");
mychoices.Add("6");
mychoices.Add("7");
mychoices.Add("8");
mychoices.Add("9");
mychoices.Add("0");
Grammar myGrammar = new Grammar(new GrammarBuilder(mychoices));
//Create the engine.
SpeechRecognitionEngine reco = new SpeechRecognitionEngine();
//Read audio stream from wav file.
reco.SetInputToWaveFile("3.wav");
reco.LoadGrammar(myGrammar);
//Get the recognized value.
reco.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(reco_SpeechRecognized);
reco.RecognizeAsync(RecognizeMode.Multiple);
}
void reco_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
MessageBox.Show(e.Result.Text); …Run Code Online (Sandbox Code Playgroud) 我怎样才能获得每1秒获得一次wav/mp3文件的Decibel值?使用任何适用于C#的音频库..
就像是:
Time: 0, DB: 0.213623
Time: 1, DB: 0.2692261
Time: 2, DB: 0.2355957
Time: 3, DB: 0.2363281
Time: 4, DB: 0.3799744
Time: 5, DB: 0.3580322
Time: 6, DB: 0.1331177
Time: 7, DB: 0.3091431
Time: 8, DB: 0.2984009
Run Code Online (Sandbox Code Playgroud)
我真的很感谢你的帮助:)
问候,
我有这个 JSON 对象:
{
"maindrawer":
{
"enabled": true,
"actions":
[
{
"type": "Section",
"title": "Section 1"
},
{
"id": 1,
"type": "Primary",
"title": "Title 1",
"badge":
{
"enabled": false,
"value": 0,
"textColor": "#000000",
"badgeColor": "#ff0990"
},
"subActions":
[
{
"id": 1,
"type": "Primary",
"title": "Sub Title 1"
}
]
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
这是我用来访问徽章 -> textColor 值的代码:
public void loadJSONFromRaw(Context context, int id)
{
json = null;
try
{
//read and return json sting
InputStream is = context.getResources().openRawResource(id);
int size …Run Code Online (Sandbox Code Playgroud) 我对这个穿线的东西还是新手.假设我有50000个URL,我想同时获取这些URL的内容,比如一起处理每10个URL.然后,一旦这些URL中的一个完成处理,程序就应该从队列列表中添加另一个,直到它完成处理列表中的所有URL.现在我怎么能用C#做到这一点..这是我到目前为止所做的代码..
class RequestState
{
public WebRequest Request;
// holds the request
public object Data;
// store any data in this
public string SiteUrl;
// holds the UrlString to match up results (Database lookup, etc).
public RequestState(WebRequest request, object data, string siteUrl)
{
this.Request = request;
this.Data = data;
this.SiteUrl = siteUrl;
}
}
private void PROCESS_URLS_Click(object sender, EventArgs e)
{
//run the process
process_URLs();
}
private int ThreadsCount = 0;
private void process_URLs()
{
//count threads number
ThreadsCount = URLS_LISTVIEW.SelectedItems.Count; …Run Code Online (Sandbox Code Playgroud) 我在最新的angularJS版本1.1.5中测试动画,看起来它不能正常工作.请检查这个小提琴
HTML:
<div ng-app>
<div ng-controller='ctrl'>
<input type='button' value='click' ng-click='clicked()' />
<div ng-show="foo == true" class='myDiv' ng-animate="{show: 'fadeIn', hide:'fadeOut'}">
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.myDiv{
width:400px;
height:200px;
background-color:red;
}
.fadeIn-setup, .fadeOut-setup {
-webkit-transition: 1s linear opacity;
-moz-transition: 1s linear opacity;
-o-transition: 1s linear opacity;
transition: 1s linear opacity;
}
.fadeIn-setup{
opacity:0;
}
.fadeOut-setup{
opacity:1;
}
.fadeIn-setup.fadeIn-start {
opacity: 1;
}
.fadeOut-setup.fadeOut-start{
opacity:0;
}
Run Code Online (Sandbox Code Playgroud)
AngularJS:
function ctrl($scope){
$scope.foo = false;
$scope.clicked = function(){
$scope.foo = !($scope.foo);
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我切换回1.1.4版本时,它工作正常但有另一个错误,他们说它已在v1.1.5中修复.现在这令人困惑.他们修复了以前的错误吗?无论如何,任何帮助将不胜感激.
我正在尝试将数据应用于模型中builder.Property(_ => _.[DYNAMIC_FIELD_NAME]).HasComment("Some comment")具有属性的所有属性。Description到目前为止,这是我使用反射的尝试:
public class User : TableFieldsBase, IEntityTypeConfiguration<User>
{
public void Configure(EntityTypeBuilder<User> builder)
{
var tableName = this.GetType().Name;
builder.ToTable(tableName);
var props = GetType().GetProperties();
foreach(var prop in props)
{
var descriptionAttr = this.GetAttributeFrom<DescriptionAttribute>(prop.Name);
if(descriptionAttr != null)
{
builder.Property(t => EF.Property<object>(t, prop.Name)).HasComment(descriptionAttr.Description);
}
}
}
[Description("This is the username")]
public string Username { get; set; }
[DisplayName("Email")]
public string Email { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我正在循环访问模型的所有属性并提取它们的描述文本。例如,Username有一个描述属性,我想用它来将其保存在数据库的“评论”字段中。这里的问题是我不确定如何在builder.Property方法中动态应用该属性。也许我以错误的方式看待它?
这是我运行此代码时遇到的错误:
Exception has occurred: CLR/System.ArgumentException
Exception …Run Code Online (Sandbox Code Playgroud) private void button1_Click(object sender, EventArgs e)
{
PROGRESS_BAR.Minimum = 0;
PROGRESS_BAR.Maximum = 100;
PROGRESS_BAR.Value = 0;
for (int i = 0; i < 100; i++)
{
Thread t = new Thread(new ThreadStart(updateProgressBar));
t.IsBackground = true;
t.Start();
}
}
private void updateProgressBar()
{
PROGRESS_BAR.PerformStep();
Thread.Sleep(4000);
}
Run Code Online (Sandbox Code Playgroud)
我总是得到这个错误:跨线程操作无效:控件''从创建它的线程以外的线程访问.
我试图在谷歌搜索解决方案,不幸的是所有这些都不适合我.有没有人知道如何解决这个问题?提前致谢..
在C#winforms应用程序中隐藏/保护包含我的服务器IP地址的字符串的最佳方法是什么?
这是事情,为了激活我创建的应用程序,用户应填写一些包含用户名和密码文本框的表单,然后连接到我的服务器以验证他输入的详细信息.
现在我想要的是隐藏/保护或者以某种方式加密包含服务器地址的字符串,因此没有人可以实际更改/访问它或者至少使它很难被反转..这可能吗?
我不确定我是否清楚这个问题,但我希望你们有这个想法......
我知道okhttp3默认情况下,该库会添加标头Accept-Encoding: gzip并自动为我们解码响应。
我要处理的主机仅接受标头的问题是:Accept-Encoding: gzip, deflate如果不添加deflate部分,它将失败。现在,当我手动将该标头添加到okhttp客户端时,该库不再对我进行解压缩。
我已经尝试了多种解决方案来获取响应并尝试手动解压缩该响应,但是我总是最终遇到一个异常,即java.util.zip.ZipException: Not in GZIP format,这是我到目前为止已经尝试的方法:
//decompresser
public static String decompressGZIP(InputStream inputStream) throws IOException
{
InputStream bodyStream = new GZIPInputStream(inputStream);
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int length;
while ((length = bodyStream.read(buffer)) > 0)
{
outStream.write(buffer, 0, length);
}
return new String(outStream.toByteArray());
}
//run scraper
scrape(api, new Callback()
{
// Something went wrong
@Override
public void onFailure(@NonNull Call call, @NonNull IOException e) …Run Code Online (Sandbox Code Playgroud) c# ×6
android ×2
java ×2
add ×1
angularjs ×1
arrays ×1
audio ×1
c++ ×1
compare ×1
decibel ×1
deflate ×1
function ×1
gzip ×1
javascript ×1
json ×1
key ×1
ng-animate ×1
ng-show ×1
obfuscation ×1
okhttp3 ×1
parsing ×1
performance ×1
php ×1
progress-bar ×1
queue ×1
sapi ×1
search ×1
string ×1
task ×1
threadpool ×1
timespan ×1
winforms ×1