Can't add scripts

When i write a script and i try to add it, it says “cant add component(scriptname)because it doesnt exists. Check to see if the file name and class name match”. How can i fix this?

the name of the class must match the name of the file