Accessing a string from an if function inside of the returned program

Accessing a string from an if function inside of the returned program



Pretty much, I want to use the variable 'username' in the program that the if function returns, however this program is located in my program.cs, and the if function is not.



Wasn't able to get the public static string in the if function, maybe this is obvious to experienced coders but I'm a beginner.



I tested it out by having the console print the variable value, with no success.



The if function:


public class WeeWoo : ChatBot
{

public static Dictionary<string, string> whitelisted;

static WeeWoo()

string json = File.ReadAllText("whitelists/walls.json");
var data = JsonConvert.DeserializeObject<dynamic>(json);
whitelisted = data.ToObject<Dictionary<string, string>>();


public override void GetTextAsync(string text)

string message = "";
string username = "";
text = GetVerbatim(text);

if (text.Contains("-> me"))

text = text.Replace("[", String.Empty).Replace("]", String.Empty).Replace(" -> me", String.Empty);
String args = text.Split(' ');
username = args[1];
message = args[2];
if (message.Equals("weewoo") && (whitelisted.ContainsKey(username)))

Program.WeeWoo();



public static string username;






I'm not completely sure what you're trying to do, but remove string username = "";, leave everything else as-is, and try running it again. Or change the constructor to accept a string, and pass in username when you call it.

– User
Sep 6 '18 at 3:45



string username = "";


username






Can you show how Json return the data...

– Saif
Sep 6 '18 at 3:53






pretty sure the issue is here username = args[1]; , you are trying to assign args[1]; which is null or empty to username, so username will not have any value

– Saif
Sep 6 '18 at 4:00


username = args[1];


args[1];


username


username






I got it by removing the string username = ""; Thank you!

– Praise Allah
Sep 6 '18 at 11:39


string username = "";




0



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ

Node.js puppeteer - Use values from array in a loop to cycle through pages