looking for some solutions? You are welcome.

SOLVED: Why does splitting a string result in Split() not a valid property

ACiD GRiM:

I am trying to write one of my first c# scripts for a homeautomation solution (homeseer). I have other issues to resolve with the below code, however the simple line:

String[] parm = line.Split(",");

Results in the error:

Type 'string' does not contain a definition for `Split' and no extension method 'Split' of type 'string' could be found (are you missing a using directive or an assembly reference?)

I will post another question for my other issues

using System;
using System.Collections.Generic;

public void Main(string line)
{
    String[] parm = line.Split(",");
    var windowDoorOpenVar = hs.GetVar("WindowDoorOpen");
    if (windowDoorOpenVar.Size == 0 || windowDoorOpenVar == null)
    {
        hs.CreateVar("WindowDoorOpen");
        List<string> windowDoorOpen = new List<string>();
    }
    else
    {
        List windowDoorOpen = windowDoorOpenVar;
    }

    switch (parm[0])
    {
        case "Open":
            windowDoorOpen.Add(parm[1]);
            break;
        case "Closed":
            windowDoorOpen.Remove(parm[1]);
            break;
    }
    hs.SaveVar("WindowDoorOpen", windowDoorOpen);
}



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent