C# 我的check and buy对象说:并非所有代码路径都返回值 使用System.Collections.Generic; 使用制度; 使用System.Web.Helpers; 使用OpenQA.Selenium; 使用OpenQA.Selenium.Chrome; 公共静态类dbcaio { 公共静态字符串间距=“|”; 公共静态字符串隐藏=“||||”(-124;|||||||”); 公共静态字符串hug=“

C# 我的check and buy对象说:并非所有代码路径都返回值 使用System.Collections.Generic; 使用制度; 使用System.Web.Helpers; 使用OpenQA.Selenium; 使用OpenQA.Selenium.Chrome; 公共静态类dbcaio { 公共静态字符串间距=“|”; 公共静态字符串隐藏=“||||”(-124;|||||||”); 公共静态字符串hug=“,c#,C#,如果您编写的方法具有以下签名 using System.Collections.Generic; using System; using System.Web.Helpers; using OpenQA.Selenium; using OpenQA.Selenium.Chrome; public static class dbcaio { public static string spacing = " | "; public static string

如果您编写的方法具有以下签名


using System.Collections.Generic;
using System;
using System.Web.Helpers;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
public static class dbcaio
{

    public static string spacing = " | ";

    public static string hide = " ||||| (- ||||| ";

    public static string hug = " <3 :) ";

    public static string sad = " :( ";

    public static string details_disclaimer = " Y/N  ";

    public static string yes = "y";

    public static string y = "y";

    public static string no = "n";

    public static string n = "n";

    public static string dab = "dab on 'em haters lmfao";

    public static string profile = "(default)";

    public static string entertext = "Please enter your";

    public static string site_enter_screech = "Which site do you want to use?";

    public static string triggered = " :( :( :( :( ";

    public static void postal_input(
        object card,
        object security_code,
        object expiry,
        object address,
        object city,
        object state,
        object phone,
        object email,
        object chosen_site,
        object site_product)
    {
        Console.WriteLine(entertext + " postal code!" + hug);
        var postal = Console.ReadLine();
        var family_list = postal.Split(' ');
        Console.WriteLine("\n");
        Console.WriteLine("Is this postal code correct? " + hug + details_disclaimer + hug);
        foreach (var name in family_list)
        {
            Console.WriteLine(name);
        }
        var response_string = Console.ReadLine();
        if (response_string == yes)
        {
            Console.WriteLine(dab + "Whew! We're done setting up... LET'S DO THIS..!" + dab);
            Console.WriteLine("____________________");
            Console.WriteLine("Loading!");
            Console.WriteLine("Loading!");
            Console.WriteLine("Loading!");
            Console.WriteLine("Loading!");
            Console.WriteLine("Loading!");
            Console.WriteLine("____________________");
            Check(card, security_code, expiry, address, city, state, phone, email, postal, chosen_site, site_product);
        }
        else if (response_string == no)
        {
            Console.WriteLine("Alright! We'll redo that, shall we! -- Oh-h no-o " + sad);
            postal_input(card, security_code, expiry, address, city, state, phone, email, chosen_site, site_product);
        }
    }

    public static void email_input(
        object card,
        object security_code,
        object expiry,
        object address,
        object city,
        object state,
        object phone,
        object chosen_site,
        object site_product)
    {
        Console.WriteLine(entertext + " email!!" + hug);
        var email = Console.ReadLine();
        var family_list = email.Split(' ');
        Console.WriteLine("\n");
        Console.WriteLine("Is this email correct? " + hug + details_disclaimer + hug);
        foreach (var name in family_list)
        {
            Console.WriteLine(name);
        }
        var response_string = Console.ReadLine();
        if (response_string == yes)
        {
            postal_input(card, security_code, expiry, address, city, state, phone, email, chosen_site, site_product);
        }
        else if (response_string == no)
        {
            Console.WriteLine("Alright! We'll redo that, shall we! -- Oh-h no-o " + sad);
            email_input(card, security_code, expiry, address, city, state, phone, chosen_site, site_product);
        }
    }

    public static void phone_input(
        object card,
        object security_code,
        object expiry,
        object address,
        object city,
        object state,
        object chosen_site,
        object site_product)
    {
        Console.WriteLine(entertext + " phone!" + hug);
        var phone = Console.ReadLine();
        var family_list = phone.Split(' ');
        Console.WriteLine("\n");
        Console.WriteLine("Is this phone correct? " + hug + details_disclaimer + hug);
        foreach (var name in family_list)
        {
            Console.WriteLine(name);
        }
        var response_string = Console.ReadLine();
        if (response_string == yes)
        {
            email_input(card, security_code, expiry, address, city, state, phone, chosen_site, site_product);
        }
        else if (response_string == no)
        {
            Console.WriteLine("Alright! We'll redo that, shall we! -- Oh-h no-o " + sad);
            phone_input(card, security_code, expiry, address, city, state, chosen_site, site_product);
        }
    }

    public static void state_input(
        object card,
        object security_code,
        object expiry,
        object address,
        object city,
        object chosen_site,
        object site_product)
    {
        Console.WriteLine(entertext + " state!" + hug);
        var state = Console.ReadLine();
        var family_list = state.Split(' ');
        Console.WriteLine("\n");
        Console.WriteLine("Is this state correct? " + hug + details_disclaimer + hug);
        foreach (var name in family_list)
        {
            Console.WriteLine(name);
        }
        var response_string = Console.ReadLine();
        if (response_string == yes)
        {
            phone_input(card, security_code, expiry, address, city, state, chosen_site, site_product);
        }
        else if (response_string == no)
        {
            Console.WriteLine("Alright! We'll redo that, shall we! -- Oh-h no-o " + sad);
            state_input(card, security_code, expiry, address, city, chosen_site, site_product);
        }
    }

    public static void city_input(
        object card,
        object security_code,
        object expiry,
        object address,
        object chosen_site,
        object site_product)
    {
        Console.WriteLine(entertext + " city!" + hug);
        var city = Console.ReadLine();
        var family_list = city.Split(' ');
        Console.WriteLine("\n");
        Console.WriteLine("Is this city correct? " + hug + details_disclaimer + hug, site_product);
        foreach (var name in family_list)
        {
            Console.WriteLine(name);
        }
        var response_string = Console.ReadLine();
        if (response_string == yes)
        {
            state_input(card, security_code, expiry, address, city, chosen_site, site_product);
        }
        else if (response_string == no)
        {
            Console.WriteLine("Alright! We'll redo that, shall we! -- Oh-h no-o " + sad, site_product);
            city_input(card, security_code, expiry, address, chosen_site, site_product);
        }
    }

    public static void address_input(
        object card,
        object security_code,
        object expiry,
        object chosen_site,
        object site_product)
    {
        Console.WriteLine(entertext + " address!" + hug);
        var address = Console.ReadLine();
        var family_list = address.Split(' ');
        Console.WriteLine("\n");
        Console.WriteLine("Is this address correct? " + hug + details_disclaimer + hug);
        foreach (var name in family_list)
        {
            Console.WriteLine(name);
        }
        var response_string = Console.ReadLine();
        if (response_string == yes)
        {
            city_input(card, security_code, expiry, address, chosen_site, site_product);
        }
        else if (response_string == no)
        {
            Console.WriteLine("Alright! We'll redo that, shall we! -- Oh-h no-o " + sad);
            address_input(card, security_code, expiry, chosen_site, site_product);
        }
    }

    //∫ç¨ß∑
    public static void expiry_input(object card, object security_code, object chosen_site, object site_product)
    {
        Console.WriteLine(entertext + " expiration date [MM/YY]!" + hug);
        var expiry = Console.ReadLine();
        var family_list = expiry.Split(' ');
        Console.WriteLine("\n");
        Console.WriteLine("Is this expiration date correct? " + hug + details_disclaimer + hug);
        foreach (var name in family_list)
        {
            Console.WriteLine(name);
        }
        var response_string = Console.ReadLine();
        if (response_string == yes)
        {
            address_input(card, security_code, expiry, chosen_site, site_product);
        }
        else if (response_string == no)
        {
            Console.WriteLine("Alright! We'll redo that, shall we! -- Oh-h no-o " + sad);
            expiry_input(card, security_code, chosen_site, site_product);
        }
    }

    public static void security_code_input(object card, object chosen_site, object site_product)
    {
        Console.WriteLine(entertext + " security code!" + hug);
        var security_code = Console.ReadLine();
        var family_list = security_code.Split(' ');
        Console.WriteLine("\n");
        Console.WriteLine("Is this security code correct? " + hug + details_disclaimer + hug);
        foreach (var name in family_list)
        {
            Console.WriteLine(name);
        }
        var response_string = Console.ReadLine();
        if (response_string == yes)
        {
            expiry_input(card, security_code, chosen_site, site_product);
        }
        else if (response_string == no)
        {
            Console.WriteLine("Alright! We'll redo that, shall we! -- Oh-h no-o " + sad);
            security_code_input(card, chosen_site, site_product);
        }
    }

    public static void site()
    {
        Console.WriteLine(site_enter_screech + hug);
        var chosen_site = Console.ReadLine();
        var family_list = chosen_site.Split(' ');
        Console.WriteLine("\n");
        Console.WriteLine("Is this the place you want to cook up dinner?");
        foreach (var name in family_list)
        {
            Console.WriteLine(name);
        }
        var response_string = Console.ReadLine();
        if (response_string == yes)
        {
            product_selection(chosen_site);
        }
        else if (response_string == no)
        {
            Console.WriteLine("Alright! We'll redo that, shall we! -- Oh-h no-o " + sad);
            site();
        }
    }

    public static void product_selection(object chosen_site)
    {
        var r = System.Net.WebRequest.Create("https://" + "www." + chosen_site + ".com" + "/products.json/");
        var products = Json.Decode(r.Method)["products"];
        foreach (var product in products)
        {
            Console.WriteLine(product["handle"]);
        }
        Console.WriteLine("Which product would you want to use? (CNTRL+C THEN CNTRL+V!!!! ALSO SELECT FROM THE LIST ABOVE!!!!)" + hug);
        var site_product = Console.ReadLine();
        var family_list = site_product.Split(' ');
        Console.WriteLine("\n");
        Console.WriteLine("Is this the place's product you want to cook up dinner with?");
        foreach (var name in family_list)
        {
            Console.WriteLine(name);
        }
        var response_string = Console.ReadLine();
        if (response_string == yes)
        {
            card_input(chosen_site, site_product);
        }
        else if (response_string == no)
        {
            Console.WriteLine("Alright! We'll redo that, shall we! -- Oh-h no-o " + sad);
            product_selection(chosen_site);
        }
    }

    public static object Check(
        object card,
        object security_code,
        object expiry,
        object address,
        object city,
        object state,
        object phone,
        object email,
        object postal,
        object chosen_site,
        object site_product)
    {
        var r = System.Net.WebRequest.Create("https://" + "www." + chosen_site + ".com" + "/products.json/");
        var checkout_page = System.Net.WebRequest.Create("https://www." + chosen_site + ".com" + "/checkout" + site_product);
        var products = Json.Decode(r.Method)["products"];
        foreach (var product in products) 
        {
            var productname = product["title"];
            var producturl = "https://www." + chosen_site + ".com/products/" + site_product;
            Console.WriteLine(product["title"]);
            Console.WriteLine(producturl);
        }
        foreach (var variant in products["variants"])
        {
            Console.WriteLine(variant["available"]);
            Console.WriteLine(variant["option2"]);
        }
        Buy(card, security_code, expiry, address, city, state, phone, email, postal, chosen_site, site_product, checkout_page);
    }

    public static object Buy(
        object card,
        object security_code,
        object expiry,
        object address,
        object city,
        object state,
        object phone,
        object email,
        object postal,
        object producturl,
        object site_product,
        object checkout_page)
    {
        Console.WriteLine("Task's are getting out of thier PJ's!");
        Console.WriteLine("Gotta blast!");
        Console.WriteLine("Going to : " + checkout_page + " from profile " + profile + " as the kitchen!");
        Console.WriteLine("Using : " + card + " from profile " + profile + " as your card!");
        Console.WriteLine("Using : " + security_code + " from profile " + profile + " as your security code!");
        Console.WriteLine("Using : " + expiry + " from profile " + profile + " as your expiration date!");
        Console.WriteLine("Using : " + address + " from profile " + profile + " as your address!");
        Console.WriteLine("Using : " + city + " from profile " + profile + " as your city!");
        Console.WriteLine("Using : " + state + " from profile " + profile + " as your state!");
        Console.WriteLine("Using : " + phone + " from profile " + profile + " as your phone number!");
        Console.WriteLine("Using : " + email + " from profile " + profile + " as your email!");
        Console.WriteLine("Using : " + postal + " from profile " + profile + " as your postal code!");
        ChromeDriver driver = new ChromeDriver();
        driver.Navigate().GoToUrl((string)producturl);
        driver.FindElement(By.XPath("button[@name=\"add\"]")).Click();
        driver.FindElement(By.XPath("button[@name=\"checkout\"]")).Click();
        driver.FindElement(By.XPath("input[@placeholder=\"Email\"]")).SendKeys((string)email);
        driver.FindElement(By.XPath("input[@placeholder=\"First name\"]")).SendKeys((string)"John");
        driver.FindElement(By.XPath("input[@placeholder=\"Last name\"]")).SendKeys((string)"Doe");
        driver.FindElement(By.XPath("input[@placeholder=\"Address\"]")).SendKeys((string)address);
        driver.FindElement(By.XPath("input[@placeholder=\"City\"]")).SendKeys((string)city);
        driver.FindElement(By.XPath("select[@name=\"checkout[shipping_address][province]\"]")).SendKeys((string)state);
        driver.FindElement(By.XPath("input[@placeholder=\"ZIP code\"]")).SendKeys((string)postal);
        driver.FindElement(By.XPath("input[@placeholder=\"Phone\"]")).SendKeys((string)phone);
        driver.FindElement(By.XPath("button[@name=\"button\"]")).Click();
        driver.FindElement(By.XPath("button[@id=\"btn-proceed-address\"]")).Click();
        driver.FindElement(By.XPath("button[@name=\"button\"]")).Click();
        driver.FindElement(By.XPath("input[@id=\"checkout_payment_gateway_3487187\"]")).Click();
        driver.FindElement(By.XPath("button[@id=\"continue_button\"]")).Click();
        driver.FindElement(By.XPath("button[@id=\"createAccount\"]")).Click();
        driver.FindElement(By.XPath("input[@name=\"cardnumber\"]")).SendKeys((string)(string)card);
        driver.FindElement(By.XPath("input[@name=\"exp-date\"]")).SendKeys((string)(string)expiry);
        driver.FindElement(By.XPath("input[@name=\"cvc\"]")).SendKeys((string)(string)security_code);
        driver.FindElement(By.XPath("input[@name=\"billingLine1\"]")).SendKeys((string)address);
        driver.FindElement(By.XPath("input[@name=\"billingCity\"]")).SendKeys((string)city);
        driver.FindElement(By.XPath("select[@name=\"billingState\"]")).SendKeys((string)state);
        driver.FindElement(By.XPath("input[@name=\"billingPostalCode\"]")).SendKeys((string)postal);
        driver.FindElement(By.XPath("input[@id=\"phone\"]")).SendKeys((string)phone);
        driver.FindElement(By.XPath("input[@value=\"Pay Now\"]")).Click();
    }

    public static void card_input(object chosen_site, object site_product)
    {
        Console.WriteLine(entertext + " card!" + hug);
        var card = Console.ReadLine();
        var family_list = card.Split(' ');
        Console.WriteLine("\n");
        Console.WriteLine("Is this card correct? " + hug + details_disclaimer + hug);
        foreach (var name in family_list)
        {
            Console.WriteLine(name);
        }
        var response_string = Console.ReadLine();
        if (response_string == yes)
        {
            security_code_input(card, chosen_site, site_product);
        }
        else if (response_string == no)
        {
            Console.WriteLine("Alright! We'll redo that, shall we! -- Oh-h no-o " + sad);
            card_input(chosen_site, site_product);
        }
    }

    static dbcaio()
    {
        site();
    }


}
这意味着该方法返回类型为
object
的对象。这意味着必须在方法末尾(或存在该方法时)返回类型为
object
的对象(或null,或隐式转换为
object


但是你没有返回任何东西。也许那些方法应该是
void

我不明白。我应该使哪些部分无效?public static void Buy()或者通过在函数中返回一个对象来实际使用返回类型“object”。您是指
公共静态对象
,而不是
公共静态无效
?以及类似地,在当前声明返回
对象
的其他方法中,即使您不是。这意味着您必须返回一个type object,我不同意这句话,你可以返回
null
。方法“Buy”应该是返回类型
void
,这是他试图说的,因为你没有返回一个对象,这就是你遇到问题的原因。
public static object Buy(...)